PDA

View Full Version : Change the date a cookie expires?


nintendo
04-01-2006, 09:09 PM
How do I change the date a cookie is set to expire, to say April 15th??

if ($vbulletin->userinfo['userid']) {
if (!$_COOKIE['hacked']) {
setcookie('hacked', '1', 1143964800);
} elseif ($_COOKIE['hacked'] < 3) {
setcookie('hacked', $_COOKIE['hacked'] + 1, 1143964800);
echo 'Put whatever hacked HTML you want here';
exit;
}
}

Cookie is setup to expire on April 2, 2006 at 12:00 am.

Code Monkey
04-01-2006, 09:48 PM
time()+60*60*24*30 will cause it to expire in 30 days. You can alter that to what you wish. The key is not to hard code the time unless you want a specific date for it to expire.

If you wanted a specific date then use the mktime function.