You are here

public function CookieJar::clear in Auth0 Single Sign On 8.2

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|null $domain Clears cookies matching a domain:

string|null $path Clears cookies matching a domain and path:

string|null $name Clears cookies matching a domain, path, and name:

Return value

CookieJarInterface

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 117

Class

CookieJar
Cookie jar that stores cookies as an array

Namespace

GuzzleHttp\Cookie

Code

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 ($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));
    });
  }
}