Re: Cookie -> Delete -> Reset
| From: | Abe Asghar | Date: | Tue, 09 Jan 2001 17:34:36 +0000 |
| Subject: | Re: Cookie -> Delete -> Reset | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-33499@lists.php.net to get a copy of this message | ||
That makes sense Rasmus, but the reason I delete and reset the cookie is
because I am trying to measure activity and not just a set time. So I have
the cookie reset every time somebody views a new page. This way it expires
a set amount of time after they last clicked on a page.
However as you can see this doesn't work. Is there a better way to do this
anyone knows?
Thanks,
Abe
----- Original Message -----
From: "Rasmus Lerdorf" <rasmus@php.net>
To: "Abe Asghar" <abe@fish.tm>
Cc: "PHP General List" <php-general@lists.php.net>
Sent: Tuesday, January 09, 2001 5:24 PM
Subject: Re: [PHP] Cookie -> Delete -> Reset
> It makes no sense to delete and set. Simply setting it will override the
> previous. Note also that using such a short expiry time puts you at the
> mercy of people having the system clocks set correctly. Many people
> don't. For short expiry cookies, I always do something like:
>
>
> setcookie('user',$user.':'.time()+1500,0,'/','.test.serve.co.uk');
>
> That is, put the timestamp in the value field. This timestamp is relative
> to the system clock on *my* server instead of the remote machine. Then to
> figure out it the cookie should actually be expired do:
>
> list($usr,$ti) = explode(':',$user);
> if($ti>time()) { ... do whatever you do when a cookie is expired ... }
>
> -Rasmus
>
> On Tue, 9 Jan 2001, Abe Asghar wrote:
>
> >
> > Hey guys,
> >
> > I wonder if U can help...
> >
> > I have the following code that reads a cookie and deletes it and then
resets a cookie of the same name. However all it seems to do is delete the
cookie and not set a new one. Any ideas what I am missing?
> >
> >
> > $user = $HTTP_COOKIE_VARS["user"];
> >
> > setcookie("user");
> >
> > setcookie("user","$user",time()+1500,"/",".test.serve.co.uk",0);
> >
> >
> > Thanks in advance,
> > Abe
> >
>