Chris Shiflett wrote:
> Jasper Bryant-Greene wrote:
> 
>> That is not true. The output to the client will look like this:
>>
>> HTTP/1.1 302 Found
>> Set-Cookie: name=value;domain=whatever
>> Location: http://my.domain.com/my.php
>> [...]
> 
> 
> Very nice explanation. :-)
> 
> It is a common misconception that header('Location: ...') redirects the
> client as soon as that statement is executed. The Location header is
> only special in the sense that PHP also modifies the response status
> code (to 302). Aside from that, it's just a regular header, and the
> browser can't possible take any action on it before it receives the HTTP
> response (which isn't sent until your PHP script completes). 

That's a bit misleading.  The HTTP response headers are sent a soon as
you output something from your script (calling header() or setcookie()
doesn't count as output, so you can set all the headers and cookies you
want).  It doesn't wait for the end of the request unless you are
buffering everything.  And the browsers tend to redirect right away once
they get this header.  Whether or not your script runs to completion
once the browser is gone is controlled by your 'ignore_user_abort'
setting.  See chapter 40 - Connection Handling in the manual for a full
explanation of that.

-Rasmus

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to