Esempio n. 1
0
 /**
  * Returns whether the Cookie matches the given origin.
  *
  * @param CookieOrigin $origin
  *
  * @return boolean
  */
 public function matches(CookieOrigin $origin)
 {
     if ($this->cookie->isSecure() && !$origin->isSecure()) {
         return false;
     }
     $requestHost = explode('.', strtolower($origin->getHost()));
     $cookieDomain = explode('.', $this->domain);
     if ($this->hostOnly && $requestHost != $cookieDomain) {
         return false;
     }
     if (count($requestHost) < count($cookieDomain)) {
         return false;
     }
     if (array_slice($requestHost, -count($cookieDomain)) != $cookieDomain) {
         return false;
     }
     $path = self::getPathDirectory($origin->getPath());
     if (substr($path, 0, strlen($this->path)) != $this->path) {
         return false;
     }
     return true;
 }