You are here

public function SetCookie::matchesDomain in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php \GuzzleHttp\Cookie\SetCookie::matchesDomain()

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 335

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