ilyalyu — 2005-10-29T05:53:53-04:00 — #1
I know how to set cookies using PHP. But how to destroy them? The only way I can invent is to set it expiry date one second in the future. However it is not quite elegant and I am not sure if the cookie will be destroyed imediately in this case or only after the user closes the browser.
spikez — 2005-10-29T06:01:13-04:00 — #2
You have to set the date to a time PREVIOUS
// set the expiration date to one hour ago
setcookie ("TestCookie", "", time() - 3600);
setcookie ("TestCookie", "", time() - 3600, "/~rasmus/", ".example.com", 1);
ilyalyu — 2005-10-29T14:57:45-04:00 — #3
In fact, in that case you should set at least one day in the past. After all local time difference can be up to one day for users in different parts of the world. So, one hour is not enough, right?
paulyg — 2005-10-29T17:01:42-04:00 — #4
set the cookie with no other values to kill it.
$name="Your cookies name";
enygmadae — 2005-10-29T20:47:38-04:00 — #5
actually, using the setcookie() function, if you don't pass the same values to the cookie as it had whren it was set (name, path, domain, security), my experience is that it changes made won't work correctly...