Reputation: 896
I am trying to send a cookie with my request to an rest api server. This cookie is needed to make requests to the API server.
But the cookie is never send. Any ideas why this is?
$cookieJar = CookieJar::fromArray([
'cookie_name' => 'cookie_value',
], '/');
$token = 'sfsdfkdsfksdf';
$body = [
'headers' => [
'Accept' => 'application/json',
'Content-type' => 'application/json',
'X-sess-id' => $token,
],
'cookies' => $cookieJar,
];
$request = $this->httpClient->request('POST', 'https://myendpoint.com', $body);
var_dump($request); exit;
I am using guzzle version 6.3.2
The request body.
Upvotes: 1
Views: 1226
Reputation: 896
It turns out that i needed to set the domain cookie and not only '/'
Upvotes: 1