tags:

views:

219

answers:

2
setcookie('id', null, 1, "/", ".domain.name");

The above will only delete a specific cookie,but how to delete them all?

And if I've set cookie[person][name], cookie[person][id], cookie[person][age],how to unset cookie[person]?

It's actually 2 questions.

+5  A: 

This should do the trick:

foreach ($_COOKIES as $c_id => $c_value)
{
    setcookie($c_id, NULL, 1, "/", ".domain.name");
}
Michal M
Will it also work for multiple dimensional array?
Don't know how exactly you expect to set a multi-dimensional array cookie unless the id is like `test[something]`
Chacha102
well, yeah, since it's referring the name of the cookie, so whatever type the cookie is, it'll be cleared.
Michal M
+1  A: 

Man, isn't it easier to just wipe out all cookies like this:

$_COOKIE=array();
AJ