Reputation: 65
So I've created a php cookie using:
setcookie("first_time");
on one html page and when i logout, I want to remove/delete the cookie. I have tried using
setcookie("first_time","", time()-3600);
setcookie("first_time","", -1,"/");
along with a whole bunch of other solutions found online but i still cant seem to delete the cookie when i log out(using google chrome to check whether the cookie is still present)
Any help would be greatly appreciated
Upvotes: 2
Views: 223
Reputation: 5982
Try specifying the /
path when you use the setcookie()
function.
When no value is specified, the default value is the current directory that the cookie is being set it. It can only be unsetted from that same directory.
Upvotes: 0
Reputation: 1451
Use the exact same code you use to set the cookie, but set the time to zero (and you can use any other content.. Even an empty content)..
If that doesn't work, you're not looking in the rigth/updated place..
JO.
Upvotes: 1