How can I send Cookies with Guzzlehttp/guzzle 6?

One more way to add a cookie to the request with Guzzle:

$url = 'https://www.example.com';
$request_options = [
  'headers' => ['Cookie' => 'COOKIE_NAME=VALUE']
];
$response = $this->httpClient->request('GET', $url, $request_options);

use GuzzleHttp\Cookie\CookieJar;

$cookieJar = CookieJar::fromArray([
    'cookie_name' => 'cookie_value'
], 'example.com');

$client->request('GET', '/get', ['cookies' => $cookieJar]);

You can read the documentation here.


Guzzle can maintain a cookie session for you if instructed using the cookies request option. When sending a request, the cookies option must be set to an instance of GuzzleHttp\Cookie\CookieJarInterface.

// Use a specific cookie jar
$jar = new \GuzzleHttp\Cookie\CookieJar;
$r = $client->request('GET', 'http://httpbin.org/cookies', [
    'cookies' => $jar
]);

You can set cookies to true in a client constructor if you would like to use a shared cookie jar for all requests.

// Use a shared client cookie jar
$client = new \GuzzleHttp\Client(['cookies' => true]);
$r = $client->request('GET', 'http://httpbin.org/cookies');

Check too the full quickstart.