You are here

public function CookieJar::extractCookies in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php \GuzzleHttp\Cookie\CookieJar::extractCookies()

Extract cookies from an HTTP response and store them in the CookieJar.

Parameters

RequestInterface $request Request that was sent:

ResponseInterface $response Response that was received:

Overrides CookieJarInterface::extractCookies

File

vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php, line 221

Class

CookieJar
Cookie jar that stores cookies an an array

Namespace

GuzzleHttp\Cookie

Code

public function extractCookies(RequestInterface $request, ResponseInterface $response) {
  if ($cookieHeader = $response
    ->getHeader('Set-Cookie')) {
    foreach ($cookieHeader as $cookie) {
      $sc = SetCookie::fromString($cookie);
      if (!$sc
        ->getDomain()) {
        $sc
          ->setDomain($request
          ->getUri()
          ->getHost());
      }
      $this
        ->setCookie($sc);
    }
  }
}