3raser Posted March 14, 2011 Share Posted March 14, 2011 Here is my code that sets the cookie for a year: //set a cookie for a year setcookie('user', $username, time()+31536000); My code that unsets it: <?php unset($_COOKIE['user']); header("LOCATION:index.php"); ?> Why doesn't it log the user out? Link to comment https://forums.phpfreaks.com/topic/230563-setting-then-destroying-cookie/ Share on other sites More sharing options...
Psycho Posted March 14, 2011 Share Posted March 14, 2011 Because that is not how you destroy a cookie. unset() is used to unset variables within the PHP system. The cookie exists on the user's computer. Why don't you take a look at the setcookie() manual - there is plenty of information there on how to destroy a cookie. Link to comment https://forums.phpfreaks.com/topic/230563-setting-then-destroying-cookie/#findComment-1187217 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.