Connecting Tech Pros Worldwide Forums | Help | Site Map

cookie question

Alexander Ross
Guest
 
Posts: n/a
#1: Jul 17 '05
referring to the code below, will the cookie expire 24 hours after its
created, or will it expire 24 hours after the last time I add a variable to
the cookie??

if ($_POST['answerok']){
if (!($_COOKIE['adagame-5q24h']))

setcookie("adagame-5q24h[]",$_POST['questionid'],time()+60*60*24,"/","",0);
else
setcookie("adagame-5q24h[]",$_POST['questionid']);
}

--
Alexander Ross
alexross@bleen.net



stephan beal
Guest
 
Posts: n/a
#2: Jul 17 '05

re: cookie question


Alexander Ross wrote:
[color=blue]
> referring to the code below, will the cookie expire 24 hours after its
> created, or will it expire 24 hours after the last time I add a variable
> to the cookie??[/color]

It will expire 24 hours after the time returned by time() (i.e., 24 horus
from when it is set/updated). Each cookie is only one variable (though the
exact content of that variable may logically be two or more pieces of
data).

--
----- stephan beal
Registered Linux User #71917 http://counter.li.org
I speak for myself, not my employer. Contents may
be hot. Slippery when wet. Reading disclaimers makes
you go blind. Writing them is worse. You have been Warned.

MeerKat
Guest
 
Posts: n/a
#3: Jul 17 '05

re: cookie question


stephan beal wrote:[color=blue]
> Alexander Ross wrote:[color=green]
>>referring to the code below, will the cookie expire 24 hours after its
>>created, or will it expire 24 hours after the last time I add a variable
>>to the cookie??[/color]
> It will expire 24 hours after the time returned by time() (i.e., 24 horus
> from when it is set/updated). Each cookie is only one variable (though the
> exact content of that variable may logically be two or more pieces of
> data).[/color]

Actually, the first time the cookie is set, it will expire after 24
hours. However, on subsequent calls to the page where the cookie is
returned, the new cookie will be a session cookie and will expire when
the browser closes.

--
MeerKat

Closed Thread