public function testConstructorAndDefaults() { $cookie = new Cookie('foo', 'bar'); $this->assertSame('foo', $cookie->getName()); $this->assertSame('bar', $cookie->getValue()); $this->assertSame(0, $cookie->getExpires()); $this->assertSame(null, $cookie->getPath()); $this->assertSame(null, $cookie->getDomain()); $this->assertFalse($cookie->isSecure()); $this->assertFalse($cookie->isHttpOnly()); }
/** * 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; }