You are here

public function CookieJar::updateFromSetCookie in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/browser-kit/CookieJar.php \Symfony\Component\BrowserKit\CookieJar::updateFromSetCookie()

Updates the cookie jar from a response Set-Cookie headers.

Parameters

array $setCookies Set-Cookie headers from an HTTP response:

string $uri The base URL:

1 call to CookieJar::updateFromSetCookie()
CookieJar::updateFromResponse in vendor/symfony/browser-kit/CookieJar.php
Updates the cookie jar from a Response object.

File

vendor/symfony/browser-kit/CookieJar.php, line 133

Class

CookieJar
CookieJar.

Namespace

Symfony\Component\BrowserKit

Code

public function updateFromSetCookie(array $setCookies, $uri = null) {
  $cookies = array();
  foreach ($setCookies as $cookie) {
    foreach (explode(',', $cookie) as $i => $part) {
      if (0 === $i || preg_match('/^(?P<token>\\s*[0-9A-Za-z!#\\$%\\&\'\\*\\+\\-\\.^_`\\|~]+)=/', $part)) {
        $cookies[] = ltrim($part);
      }
      else {
        $cookies[count($cookies) - 1] .= ',' . $part;
      }
    }
  }
  foreach ($cookies as $cookie) {
    try {
      $this
        ->set(Cookie::fromString($cookie, $uri));
    } catch (\InvalidArgumentException $e) {

      // invalid cookies are just ignored
    }
  }
}