|
Posted by Chris B on 06/13/05 18:27
Jam Pa wrote:
> I have a page with some cookie functionality.
>
> I set the cookie, and 'setCookie' returns true (=success).
>
> However 'print_r($_COOKIE)' shows that no cookies were set.
>
> I can set cookies with javascript just fine. This cookie-fumbling takes
> place before anything else (ie. before any output).
>
> I cant seem to find a solution - what to try next?
It's as Oli said, but to supplement.
PHP is server side only. That means when you tell the php compiler to
make a page, the page is processed (and in this case the cookie is set
on the client side). Once the page has been processed PHP has absolutely
no access to it until a reload. That means it can't read the cookie off
the client until a refresh is done, at that point the cookies will be
sent up with the browser request (i.e. the browser sends "give me this
page: .. the referrer is: .. the client is: .. I have the following
cookies set for this domain: ..) etc etc.
Javascript OTOH is client side, meaning it can set a cookie after the
page has loaded, and it can revoke that cookie after the page has
loaded, in fact it can do anything after the page has loaded without the
need for a refresh.
Navigation:
[Reply to this message]
|