Hey guys,
First time posting. Anyone know a way to clear out all the cookies under / without knowing the exact names? The only way I found to clear a cookie is by using setcookie(), but you have to konw the exact name.
I tried clearing the cookies by clearing the array $_COOKIE but that didn't work. Any info appreciated.
Clearing Cookies without knowing the names
Moderator: General Moderators
You can retrieve the names from $_COOKIE and use them with setcookie().
Code: Select all
foreach($_COOKIE as $name=>$value) {
setcookie(...Thanks. I remember trying this but don't remember having the desired outcome, not sure the details.
What if you don't know the path, in setcookie?
For example
foreach($_COOKIE as $name=>$value) {
setcookie($name, '', time()-42000, '/');
}
So this would clear all the cookie values that were set under path '/'
Would it clear all the cookie values under /aaa/bbb/cc as well?
The manual was not so clear on this.
What if you don't know the path, in setcookie?
For example
foreach($_COOKIE as $name=>$value) {
setcookie($name, '', time()-42000, '/');
}
So this would clear all the cookie values that were set under path '/'
Would it clear all the cookie values under /aaa/bbb/cc as well?
The manual was not so clear on this.