Re: session cookies

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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). This is similar to how a browser can't predict when you're going to set a cookie. :-)

Just to counter my own explanation (what the heck), I do recall older versions of IE mishandling (surprise) an HTTP response such as what Jasper illustrated. They would request the new URL but fail to set the cookie as requested. It was a browser bug, and I think this bug is the source of all the confusion.

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux