How to retrieve cookies from Guzzle client?



How can I retrieve the cookies from a Guzzle request / client, after a request has occurred?

$client = new Client([
    'base_uri' => '',
$response = $client->request('GET', '/');


Read the docs, please. You have to use CookieJar class to work with cookies.

$client = new \GuzzleHttp\Client(['cookies' => true]);
$r = $client->request('GET', '');

$cookieJar = $client->getConfig('cookies');

Answered By – Alexey Shokov

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More