xyn Posted October 8, 2007 Share Posted October 8, 2007 Hi. I've not used cookies much, but I started to try and use them, I understand to unset them the expirey date /time needs to be in the past. i've used... <? $cookie_name = "testCookie"; if(!$_COOKIE[$cookie_name]){ setcookie($cookie_name, "true", time()+(14*24*60*60)); # 2 weeks. echo("setting"); } else{ if($_GET[x] == 1){ setcookie($cookie_name, "true", time()-(14*24*60*60)); # 2 weeks Ago. } print_r($_COOKIE); } ?> it doesnt seem to expire the cookie. Quote Link to comment https://forums.phpfreaks.com/topic/72289-unsetting-cookies/ Share on other sites More sharing options...
MasterACE14 Posted October 8, 2007 Share Posted October 8, 2007 <?php setcookie($cookie_name, "true", time()-3600); ?> will destroy the cookie, the 3600 is the amount of seconds in 1 hour. So this cookie is being set to expire 1 hour ago. Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/72289-unsetting-cookies/#findComment-364591 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.