cookie question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
punctweb
Forum Newbie
Posts: 11
Joined: Mon Aug 30, 2004 5:53 pm
Location: Romania, Tulcea
Contact:

cookie question

Post by punctweb »

I have a question: when you set a cookie using setcookie(), that cookie lives as long as you specified, right ? Right. Let's say that i have a cookie that lives 3 hours. How can i find out how much time has remained until that cookie expires ? Where is stored the cookie time ? Can i use it in a variable, let's say $timout = cookie_time; ?

Thanks in advance and excuse my english.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

when sent back, the cookie data only contains the value you set it to. So, you could store the time you set for it to die, inside that value, or store it on the server somewhere.
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Code: Select all

set_cookie("cookie_name", "cookie_value",time()+3600,"/");
User avatar
punctweb
Forum Newbie
Posts: 11
Joined: Mon Aug 30, 2004 5:53 pm
Location: Romania, Tulcea
Contact:

Post by punctweb »

ok, since there is no other option, i choosed to set a value in the cookie equal to the time when that cookie was created...
Post Reply