note 63177 deleted from function.header by betz

From: Date: Thu, 16 Mar 2006 10:56:06 +0000
Subject: note 63177 deleted from function.header by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-105919@lists.php.net to get a copy of this message
Note Submitter: deload at web dot de Reason: in docs ---- One thing I am not tired to say again and again is that you should exit() immediately after using a header("Location: http://www.example.com"); This is something I did not find mentioned here explicit enough. You don not only have to make sure that no code is executed after header("Location: .....") but you have to make sure the script is terminated! The "unpredictable results" when you omit the exit() are that your server might forget to close the connection after the redirect. One of my customers has got a rather big website with lots of traffic and it took me quite some time to figure out why sometimes page delivery failed and the browser was stuck loading the redirect target. This is a phenomenon that occurs more often when your server has to stand some load beyond 100%. So my contribution to this useful archive of comments is: ALWAYS put an exit() IMMEDIATELY after header("Location: http://www.example.com")!

« previous php.notes (#105919) next »