...

View Full Version : Cookies with PHP/JS



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

Thanks

Fumigator
07-09-2007, 04: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:


<?php
// 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.

http://us2.php.net/manual/en/function.setcookie.php



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum