public function addFromResponse(ResponseInterface $response, RequestInterface $request)
    {
        $uri = $request->getUri();
        $host = $uri->getHost();
        $path = $uri->getPath() ?: '/';

        $cookies = static::parseSetCookieHeader($response->getHeader('Set-Cookie'));
        $cookies = $this->setRequestDefaults($cookies, $host, $path);
        $new = clone $this;
        foreach ($cookies as $cookie) {
            $new->cookies[$cookie->getId()] = $cookie;
        }
        $new->removeExpiredCookies($host, $path);

        return $new;
    }
public function addFromResponse(ResponseInterface $response, RequestInterface $request)
    {
        $uri = $request->getUri();
        $host = $uri->getHost();
        $path = $uri->getPath() ?: '/';

        $cookies = static::parseSetCookieHeader($response->getHeader('Set-Cookie'));
        $cookies = $this->setRequestDefaults($cookies, $host, $path);
        $new = clone $this;
        foreach ($cookies as $cookie) {
            $new->cookies[$cookie->getId()] = $cookie;
        }
        $new->removeExpiredCookies($host, $path);

        return $new;
    }
public function addFromResponse ( ResponseInterface $ response , RequestInterface $ request ) { $ uri = $ request -> getUri ( ) ; $ host = $ uri -> getHost ( ) ; $ path = $ uri -> getPath ( ) ? : '/' ; $ cookies = static :: parseSetCookieHeader ( $ response -> getHeader ( 'Set-Cookie' ) ) ; $ cookies = $ this -> setRequestDefaults ( $ cookies , $ host , $ path ) ; $ new = clone $ this ; foreach ( $ cookies as $ cookie ) { $ new -> cookies [ $ cookie -> getId ( ) ] = $ cookie ; } $ new -> removeExpiredCookies ( $ host , $ path ) ; return $ new ; }
Create a new collection that includes cookies from the response.

@param \Psr\Http\Message\ResponseInterface $response Response to extract cookies from.
@param \Psr\Http\Message\RequestInterface $request Request to get cookie context from.
@return static
Create a new collection that includes cookies from the response .