title: GuzzleHttp:how can I save cookies from a POST response and use it in the next POST?
body: <p>I'm using Guzzle to login my API site, and in the moment Im login with the right credentials, I get back a cookie with a RefreshToken to send it in the next call, here is my simple (and working well) code:</p>
  
  <pre><code>$client = new Client(array(
              'cookies' =&gt; true
          ));
  
  
          $response = $client-&gt;request('POST', 'http://myapi.com/login', [
              'timeout' =&gt; 30,
              'form_params' =&gt; [
                  'email' =&gt; $request-&gt;get('email'),
                  'password' =&gt; $request-&gt;get('password'),
              ]
          ]);
  </code></pre>
  
  <p>and I get back the right response with a cookie, I can see the cookie by using:</p>
  
  <pre><code>$newCookies = $response-&gt;getHeader('set-cookie');
  </code></pre>
  
  <p>now, I need to use this cookie in the next calls, and I know Guzzle can save the cookie for me and send it automatically (or not) in the next call using a "CookieJar" or "SessionCookieJar", I have tried to use it but I do not see the cookie in the 'jar', here is what I have done:</p>
  
  <pre><code>$cookieJar = new SessionCookieJar('SESSION_STORAGE', true);
  
          $client = new Client([
            'cookies' =&gt; $cookieJar
          ]);
  
          $response = $client-&gt;request ....
  </code></pre>
  
  <p>but, when I get the cookie back from the POST, I can see it only by using:</p>
  
  <pre><code>$newCookies = $response-&gt;getHeader('set-cookie');
  </code></pre>
  
  <p>and its not in the cookieJar, so it won't send it in the next call..
  what am I missing here?</p>
  
  <p>Thank you!</p>