Jump to content

Setting, then destroying cookie


Recommended Posts

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:





Why doesn't it log the user out?

Link to comment
Share on other sites

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
Share on other sites


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.