By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,156 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

cookie question

P: n/a
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
al******@bleen.net
Jul 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Alexander Ross wrote:
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??


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.

Jul 16 '05 #2

P: n/a
stephan beal wrote:
Alexander Ross wrote:
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??

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).


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

Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.