Jump to content

$_COOKIE question


dhimok

Recommended Posts

I would like to add some more details:

 

Lets say I store a cookie when a user enters my page that will expire in 1 year. Next time the same user enters the page it wont set the cookie again, unless its not there. Now I want that cookie which is stored to expire in 3 days. Is this possible and if yes then how

Link to comment
https://forums.phpfreaks.com/topic/57309-_cookie-question/#findComment-283322
Share on other sites

This is what I did. I think its ok

 


if(!isset($_COOKIE["uid"])) {
$uid =  sha1(session_id().@time()); 
$expire1 = 365*24*3600; // 1 year
setcookie("uid", $uid, (time() + $expire)); 
} else {
$expire2 = 7*24*3600; // 1 week;
setcookie("uid", $_COOKIE["uid"], (time() + $expire2)); 
}

 

Any other ideas would be appriciated

Link to comment
https://forums.phpfreaks.com/topic/57309-_cookie-question/#findComment-283337
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.