You are here: Re: [PHP] session cookies « PHP « IT news, forums, messages
Re: [PHP] session cookies

Posted by Chris Shiflett on 09/02/05 01:49

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/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация