Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function addCookie(CookieInterface $cookie)
 {
     if (!$cookie->hasName() || $this->hasCookie($cookie)) {
         return;
     }
     if (!$cookie->hasValue()) {
         $this->clear($cookie->getAttribute(CookieInterface::ATTR_DOMAIN), $cookie->getAttribute(CookieInterface::ATTR_PATH), $cookie->getName());
         return;
     }
     foreach ($this->cookies as $jarCookie) {
         if (!$cookie->compare($jarCookie)) {
             continue;
         }
         if ($cookie->getExpires() > $jarCookie->getExpires()) {
             $this->removeCookie($jarCookie);
             continue;
         }
         if ($cookie->getValue() !== $jarCookie->getValue()) {
             $this->removeCookie($jarCookie);
             continue;
         }
         return;
     }
     $this->cookies[] = $cookie;
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function compare(CookieInterface $cookie)
 {
     return $this->name === $cookie->getName() && $this->getAttribute(self::ATTR_DOMAIN) === $cookie->getAttribute(self::ATTR_DOMAIN) && $this->getAttribute(self::ATTR_PATH) === $cookie->getAttribute(self::ATTR_PATH);
 }