You are here: Re: $_COOKIE variable is always empty « All PHP « IT news, forums, messages
Re: $_COOKIE variable is always empty

Posted by Seansan on 03/03/07 23:23

J.O. Aho wrote:
> 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).
>
>

Thank you for your answer. setcookie() has been called correctly and
with all the arguments. (this was just a simple example).

The cookies are stored on the client, and also sent to the server. I
have tested with firefox and IE. There is something happening serverside
that either changes the COOKIE value, doesnt allow it to be set, of has
another hash where it is stored.

Any more ideas?

 

Navigation:

[Reply to this 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

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