public function CookieJar::clear in Lockr 7.3
Remove cookies currently held in the cookie jar.
Invoking this method without arguments will empty the whole cookie jar. If given a $domain argument only cookies belonging to that domain will be removed. If given a $domain and $path argument, cookies belonging to the specified path within that domain are removed. If given all three arguments, then the cookie with the specified name, path and domain is removed.
Parameters
string $domain Clears cookies matching a domain:
string $path Clears cookies matching a domain and path:
string $name Clears cookies matching a domain, path, and name:
Return value
Overrides CookieJarInterface::clear
1 call to CookieJar::clear()
- CookieJar::removeCookieIfEmpty in vendor/
guzzlehttp/ guzzle/ src/ Cookie/ CookieJar.php - If a cookie already exists and the server asks to set it again with a null value, the cookie must be deleted.
File
- vendor/
guzzlehttp/ guzzle/ src/ Cookie/ CookieJar.php, line 115
Class
- CookieJar
- Cookie jar that stores cookies as an array
Namespace
GuzzleHttp\CookieCode
public function clear($domain = null, $path = null, $name = null) {
if (!$domain) {
$this->cookies = [];
return;
}
elseif (!$path) {
$this->cookies = array_filter($this->cookies, function (SetCookie $cookie) use ($path, $domain) {
return !$cookie
->matchesDomain($domain);
});
}
elseif (!$name) {
$this->cookies = array_filter($this->cookies, function (SetCookie $cookie) use ($path, $domain) {
return !($cookie
->matchesPath($path) && $cookie
->matchesDomain($domain));
});
}
else {
$this->cookies = array_filter($this->cookies, function (SetCookie $cookie) use ($path, $domain, $name) {
return !($cookie
->getName() == $name && $cookie
->matchesPath($path) && $cookie
->matchesDomain($domain));
});
}
}