How to destroy cookies using PHP?

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.

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/", "", 1);


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?

set the cookie with no other values to kill it.

$name="Your cookies name";

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…