note 63177 added to function.header

From: Date: Wed, 15 Mar 2006 11:19:46 +0000
Subject: note 63177 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-105854@lists.php.net to get a copy of this message
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")! ---- Server IP: 217.160.72.57 Probable Submitter: 212.202.129.6 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit -- http://master.php.net/note/edit/63177 Del: integrated -- http://master.php.net/note/delete/63177/integrated Del: useless -- http://master.php.net/note/delete/63177/useless Del: bad code -- http://master.php.net/note/delete/63177/bad+code Del: spam -- http://master.php.net/note/delete/63177/spam Del: non-english -- http://master.php.net/note/delete/63177/non-english Del: in docs -- http://master.php.net/note/delete/63177/in+docs Del: other reasons-- http://master.php.net/note/delete/63177 Reject -- http://master.php.net/note/reject/63177 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#105854) next »