I've tried searching the php manual and internet on how to delete cookies and I've tried it the exact same way they all say:
setcookie("name", '', 1);
or
setcookie("name", '', time()-3600);
But when I check the cookies in the cookies dialog in Firefox, it's still there with the same value. I set this cookie using the following line:
setcookie("name", $value, time() + 259200, $path);
I found this question on stackoverflow: , but none of the answers solved the problem. I also tried putting all paramaters in, like the author said, but it had no effect.
Does anyone see the problem?
I'm surprised no one has posted this yet, but this works perfectly for me:
To CREATE or CHANGE cookie by name:
To DELETE a cookie by name:
I sugest to using
at the firts l
Just like is said in the correct answer (I want it to send an updated one), to unset, every parameter used to set the cookie is necessary, even secure and httponly
Set
Unset
set a cookie
setcookie('cookiename', $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day
unset cookie
setcookie('cookiename', '', time() - 3600, "/");
No need to panic. Just copy function you use to set cookie and now minus the time. Do not get confuse, make it easy and clear.
This did the trick for me: