public function testCookieToStringReturnsHeaderFormattedString() { $cookieHeader = new Cookie(); $cookieHeader->foo = 'bar'; $this->assertEquals('Cookie: foo=bar', $cookieHeader->toString()); }
/** * Return a subset of a domain-matching cookies that also match a specified path * * @param array $dom_array * @param string $path * @return array */ protected function _matchPath($domains, $path) { $ret = array(); foreach ($domains as $dom => $paths_array) { foreach (array_keys($paths_array) as $cpath) { if (Cookie::matchCookiePath($cpath, $path)) { if (!isset($ret[$dom])) { $ret[$dom] = array(); } $ret[$dom][$cpath] = $paths_array[$cpath]; } } } return $ret; }
/** * Prepare Cookies * * @param string $domain * @param string $path * @param bool $secure * @return Header\Cookie|bool */ protected function prepareCookies($domain, $path, $secure) { $validCookies = array(); if (!empty($this->cookies)) { foreach ($this->cookies as $id => $cookie) { if ($cookie->isExpired()) { unset($this->cookies[$id]); continue; } if ($cookie->isValidForRequest($domain, $path, $secure)) { // OAM hack some domains try to set the cookie multiple times $validCookies[$cookie->getName()] = $cookie; } } } $cookies = Header\Cookie::fromSetCookieArray($validCookies); $cookies->setEncodeValue($this->config['encodecookies']); return $cookies; }
/** * Prepare Cookies * * @param string $uri * @param string $domain * @param boolean $secure * @return Cookie|boolean */ protected function prepareCookies($domain, $path, $secure) { $validCookies = array(); if (!empty($this->cookies)) { foreach ($this->cookies as $id => $cookie) { if ($cookie->isExpired()) { unset($this->cookies[$id]); continue; } if ($cookie->isValidForRequest($domain, $path, $secure)) { $validCookies[] = $cookie; } } } $cookies = Cookie::fromSetCookieArray($validCookies); return $cookies; }
public function testLocaleInCookieIsReturnedIfNameChanged() { $cookie = new Cookie(); $cookie->offsetSet('foo_cookie', 'foo'); $event = $this->event; $event->setSupported(array('foo')); $event->getRequest()->getHeaders()->addHeader($cookie); $strategy = $this->strategy; $strategy->setCookieName('foo_cookie'); $locale = $strategy->detect($event); $this->assertEquals('foo', $locale); }