|
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]
|