|
Posted by J.O. Aho on 03/03/07 23:04
Seansan wrote:
> Hi,
>
> When I run the following in PHP then two cookies are set.
>
> ini_set('session.name', 'session-1');
> session_start();
> setcookie('session-2', '');
>
>
> Both cookies are being sent to the client, and then to the server (I am
> sure), but they are not available in $_COOKIE (this array is empty).
>
> Why and how can the $_COOKIE variable be empty - this is getting
> frustrating. Am I missing something? All other global variables are
> available normally, only $_COOKIE is always empty.
Even if sessions many times are cookies, they don't use the $_COOKIE
array, but $_SESSION, as you want to be able to access a session the
same way no matter if it's embedded into url or as a cookie.
I suggest you take a look at
http://www.php.net/manual/en/ref.session.php
http://www.php.net/manual/en/function.session-start.php
to see how session works
setcookie() may require you to specify all the arguments, seems to be a
long lived msie bug that makes it to not save a cookie and also keep in
mind that you can't access a cookie value until the script after the one
where you created (the same applies to value changes).
--
//Aho
Navigation:
[Reply to this message]
|