View Full Version : Cookies with PHP/JS

07-09-2007, 04:47 PM
If I create a cookie in JS can I remove it in PHP? If so, can someone tell me how?


07-09-2007, 05:24 PM
echo the $_COOKIE global array to find out. To delete a cookie, use setcookie() with a time in the past.

Example from the manual:

// set the expiration date to one hour ago
setcookie ("TestCookie", "", time() - 3600);
setcookie ("TestCookie", "", time() - 3600, "/~rasmus/", ".example.com", 1);

Note from the manual:

Cookies must be deleted with the same parameters as they were set with. If the value argument is an empty string, or FALSE, and all other arguments match a previous call to setcookie, then the cookie with the specified name will be deleted from the remote client.