Re: Cookie -> Delete -> Reset
| From: | Rasmus Lerdorf | Date: | Tue, 09 Jan 2001 17:24:52 +0000 |
| Subject: | Re: Cookie -> Delete -> Reset | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-33489@lists.php.net to get a copy of this message | ||
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
>