title: Cannot sent cookie with Guzzle request
body: <p>I have a PHP script that needs to fetch a CSV file from an application. There is an API for the application that allows the script to lot in, which gives the script a session cookie for authentication. I then need to doa GET request to fetch the CSV file (which the API does not support).</p>
  
  <p>Using curl directory works:</p>
  
  <pre><code>$c = curl_init($url);
  curl_setopt($c, CURLOPT_COOKIE, 'PHPSESSID=' . $session_id_from_api);
  curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  $csv_file = curl_exec($c);
  echo $csv_file;
  </code></pre>
  
  <p>That fetches the CSV file using the session ID obtained from the API login and passed through a coookie.</p>
  
  <p>Now, I would like to do the same thing using Guzzle, but I just get the login page back instead. This is the code I'm using:</p>
  
  <pre><code>$client = new Guzzle\Http\Client();
  $request = $client-&gt;get(
      $url,
      [
          'cookies' =&gt; ['PHPSESSID' =&gt; $session_id_from_api],
      ]
  );
  $response = $client-&gt;send($request);
  echo $response-&gt;getBody(true);
  </code></pre>
  
  <p>That gives me the login page, so the GET to the application is not recognising the session defined by the cookie.</p>
  
  <p>Is there anything else I need to do to ensure the cookie and value I specify is sent to the remote application?</p>
  
  <p>Edit: looking at <code>$request-&gt;getRawHeaders()</code>, I see this line in the headers:</p>
  
  <pre><code>cookies: vec6nb1egvvui6op7qr7b0oqf6
  </code></pre>
  
  <p>That obviously isn't right. The documentation for my version of Guzzle gives this example:</p>
  
  <pre><code>// Enable cookies and send specific cookies
  $client-&gt;get('/get', ['cookies' =&gt; ['foo' =&gt; 'bar']]);
  </code></pre>
  
  <p>which looks to me to be consistent with what I am passing to Guzzle.</p>
  
  <p>Just to be clear, I am not trying to manage cookies in both directions over multiple requests, so there is no need to store any cookies. I have a cookie name and its value (from another source), and I just want to make sure that name and value gets sent to the destination for a single GET request. I'm not trying to "maintain a session", but in a way I am having a session passed to me from another part of the application (not Guzzle) and need to set my Guzzle request up to use it.</p>