You are here

public function SetCookie::matchesDomain in Auth0 Single Sign On 8.2

Check if the cookie matches a domain value

Parameters

string $domain Domain to check against:

Return value

bool

File

vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php, line 334

Class

SetCookie
Set-Cookie object

Namespace

GuzzleHttp\Cookie

Code

public function matchesDomain($domain) {

  // Remove the leading '.' as per spec in RFC 6265.
  // http://tools.ietf.org/html/rfc6265#section-5.2.3
  $cookieDomain = ltrim($this
    ->getDomain(), '.');

  // Domain not set or exact match.
  if (!$cookieDomain || !strcasecmp($domain, $cookieDomain)) {
    return true;
  }

  // Matching the subdomain according to RFC 6265.
  // http://tools.ietf.org/html/rfc6265#section-5.1.3
  if (filter_var($domain, FILTER_VALIDATE_IP)) {
    return false;
  }
  return (bool) preg_match('/\\.' . preg_quote($cookieDomain, '/') . '$/', $domain);
}