/** * {@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; }