setcookie('id', null, 1, "/", ".domain.name");
The above will only delete a specific cookie, but ho开发者_如何学编程w to delete them all?
This should do the trick:
foreach ($_COOKIES as $c_id => $c_value)
{
setcookie($c_id, NULL, 1, "/", ".domain.name");
}
if (isset($_SERVER['HTTP_COOKIE']))
{
$cookies = explode(';', $_SERVER['HTTP_COOKIE']);
foreach ($cookies as $cookie)
{
$parts = explode('=', $cookie);
$name = trim($parts[0]);
setcookie($name, '', time() - 1000);
setcookie($name, '', time() - 1000, '/');
}
}
Man, isn't it easier to just wipe out all cookies like this:
$_COOKIE=array();
精彩评论