setcookie('id', null, 1, "/", ".domain.name");
以上只会删除一个特定的cookie,但是如何删除它们呢?
答案 0 :(得分:13)
这应该可以解决问题:
foreach ($_COOKIES as $c_id => $c_value)
{
setcookie($c_id, NULL, 1, "/", ".domain.name");
}
答案 1 :(得分:0)
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, '/');
}
}
答案 2 :(得分:-10)
男人,要消除这样的所有饼干是不是更容易:
$_COOKIE=array();