I use Guzzle to log into my API site, and the moment I log in with the correct credentials, I return a cookie with RefreshToken to send it the next call, here is my simple (and well working) code:
$client = new Client(array( 'cookies' => true )); $response = $client->request('POST', 'http://myapi.com/login', [ 'timeout' => 30, 'form_params' => [ 'email' => $request->get('email'), 'password' => $request->get('password'), ] ]);
and I will return the correct answer with the cookie, I see the cookie with:
$newCookies = $response->getHeader('set-cookie');
now, I need to use this cookie in future calls, and I know that Guzzle can save the cookie for me and send it automatically (or not) the next time I call it with "CookieJar" or "SessionCookieJar", I have tried to use it but I donโt see the cookie in "jar", here is what I did:
$cookieJar = new SessionCookieJar('SESSION_STORAGE', true); $client = new Client([ 'cookies' => $cookieJar ]); $response = $client->request ....
but when I get the cookie from POST, I only see it with:
$newCookies = $response->getHeader('set-cookie');
and itโs not in the cookieJar, so it wonโt send it on the next call. What am I missing here?
Thanks!