Reply to Re: [PHP] session cookies

Your name:

Reply:


Posted by Rasmus Lerdorf on 09/02/05 03:31

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

[Back to original 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

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