PHP Class symfony\component\browserkit\ Cookie Code Examples

PHP symfony\component\browserkit\Cookie - 3 examples found. These are the top rated real world PHP examples of class symfony\component\browserkit\Cookie extracted from open source projects. You can rate examples to help us improve the quality of examples
Author: Fabien Potencier (fabien@symfony.com)
 /**
  * Parse the standard `Header-name: value' headers into
  * individual header name/value pairs
  *
  * @param string $header
  */
 private function parseHeader($header)
 {
     if (empty($header)) {
         return;
     }
     $pos = strpos($header, ": ");
     if (false !== $pos) {
         $name = trim(substr($header, 0, $pos));
         $value = substr($header, $pos + 2);
         if (strtolower($name) == "set-cookie") {
             $cookie = CookieParser::fromString($value);
             $this->cookies[] = new Cookie($cookie->getName(), $cookie->getRawValue(), (int) $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
         } else {
             $this->headers[$name] = $value;
         }
     }
 }
Example #2
1
 public function testIsExpired()
 {
     $cookie = new Cookie('foo', 'bar');
     $this->assertFalse($cookie->isExpired(), '->isExpired() returns false when the cookie never expires (null as expires time)');
     $cookie = new Cookie('foo', 'bar', time() - 86400);
     $this->assertTrue($cookie->isExpired(), '->isExpired() returns true when the cookie is expired');
     $cookie = new Cookie('foo', 'bar', 0);
     $this->assertFalse($cookie->isExpired());
 }
Example #3
1
 /**
  * {@inheritdoc}
  */
 public function updateFromResponse(Response $response, $uri = null)
 {
     foreach ($response->getHeader('Set-Cookie', false) as $cookie) {
         $this->set(Cookie::fromString(urldecode($cookie), $uri));
     }
 }