public function testFromSetCookieHeaderSetsCookieAttributes() { $cookie = new Cookie(); $cookie->fromSetCookieHeader('SESSION=asdf; expires=' . date('r', strtotime('2000-01-01 00:00:00')) . '; path=/; domain=.example.com; secure', 'www.example.com'); $this->assertEquals('SESSION', $cookie->getName()); $this->assertEquals('asdf', $cookie->getValue()); $this->assertEquals(array('expires' => date('r', strtotime('2000-01-01 00:00:00')), 'path' => '/', 'domain' => '.example.com', 'secure' => null), $cookie->getAttributes()); }
/** * Adds a cookie to the current cookie jar. * * @param Cookie $cookie A cookie object */ public function addCookie(Cookie $cookie) { foreach ($this->cookies as $key => $_cookie) { if ($_cookie->getName() == $cookie->getName()) { $this->cookies[$key] = $cookie; return; } } $this->cookies[] = $cookie; }