You are here

public function CookieJar::extractCookies in Lockr 7.3

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 228

Class

CookieJar
Cookie jar that stores cookies as 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());
      }
      if (0 !== strpos($sc
        ->getPath(), '/')) {
        $sc
          ->setPath($this
          ->getCookiePathFromRequest($request));
      }
      $this
        ->setCookie($sc);
    }
  }
}