Reply to Re: [PHP] setcookie issue

Your name:

Reply:


Posted by Chris Shiflett on 03/27/05 21:29

John Hinton wrote:
> The thing is, on the next action switch
>
> print_r($_COOKIE);
>
> returns empty until I refresh the browser. So, thusly, the second page
> load brings in the cookies.

$_COOKIES is a convenient array that contains the contents of the Cookie
header, nicely parsed.

Whenever you set a cookie, you're really adding a Set-Cookie header to
the response. Thus, the browser has no way of knowing your intent until
it receives the response. This data won't be in $_COOKIES until a
subsequent request is made in which that cookie is included in the
Cookie request header.

This chapter of HTTP Developer's Handbook explains cookies:

http://shiflett.org/books/http-developers-handbook/chapters/11

See Figure 11.3 for an illustration of the exchange I just described.

Hope that helps.

Chris

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

[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

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