Re: Re: coockie expiration problems
| From: | Tom Rogers | Date: | Tue, 03 Sep 2002 02:24:15 +0000 |
| Subject: | Re: Re: coockie expiration problems | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-114973@lists.php.net to get a copy of this message | ||
Hi,
Tuesday, September 3, 2002, 12:53:22 AM, you wrote:
a> OK, I found the reason, but not the solution yet:
a> The cookie time during setting is the time taken from the server. The time
a> for checking the coockie is the time of the local machine!!
a> So what can I do if I would like to last the coockie for 1 hour and the
a> person is sitting on the other site of the world running 10 hours time
a> difference? Puhh.. maybe I am wrong, but this is how it seems to be.
a> Any ideas?
a> Andy
a> <nicos@php.net> schrieb im Newsbeitrag
a> news:20020902110801.14902.qmail@pb1.pair.com...
>> Hi,
>> I see really nothing wrong in your example. Did you tried to verify
a> with
>> isset() if the cookie is still here or not?
>> And well, you should use double quote on setcookie("referrer",
a> $user_id,
>> time()+10);
>> You call should be also $_COOKIE['referrer'] and not
a> $_COOKIE[referrer].
>>
>> --
>> Merci de nous avoir choisi. - Thanks you for your choice.
>> Nicos - CHAILLAN Nicolas
>> nicos@worldakt.com
>> nicos@php.net
>> www.GroupAKT.com - Hébergement Group.
>> www.WorldAKT.com - Hébergement de sites Internet
>> "Andy" <news.letters@gmx.de> a écrit dans le message de news:
>> 20020902105136.94808.qmail@pb1.pair.com...
>> > Hi there,
>> >
>> > I am trying to save a var inside a cookie for a certain time (in this
>> > example 10s):
>> > setcookie('referrer', $user_id, time()+10); //expires in one hour
>> >
>> > Now I would like to get the value, but only if the coockie is valid (if
>> > cockie not older than 10 s in this example)
>> > echo 'referrer: '.$_COOKIE[referrer];
>> >
>> > Unfortunatelly this does not work, the cockie value is always valid,
a> even
>> > after expiration time.
>> >
>> > What am I doing wrong?
>> >
>> > Thanx for any help on that,
>> >
>> > Andy
>> >
>> >
>>
>>
According to netscape the cookie date value is expected to be in the
GMT time zone only so that is not the problem. This is more likely the
cause (from Netscape again)
<quote>
The expires header lets the client know when it is safe to purge the mapping
but the client is not required to do so.
A client may also delete a cookie before it's expiration date arrives
if the number of cookies exceeds its internal limits
</quote>
What you will have to do is encode your time in the value passed with
the cookie and do your own checking...ignoring it if it is older than
10 seconds
--
regards,
Tom