title: Reading Cookie when using Curl in php, how to?
body: <p>I am connecting to an API service which authenticates users using cookies.
  I make these two statements from command prompt and it works.</p>
  
  <pre><code>curl -d "u=username&amp;p=password" -c ~/cookiejar https://domain/login
  
  curl -b https://domain/getData
  </code></pre>
  
  <p>Now I want to make two equivalent php files <strong>login.php</strong> and <strong>get_data.php</strong> using curl.</p>
  
  <p>I am using </p>
  
  <pre><code>curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);
  </code></pre>
  
  <p>in <code>login.php</code></p>
  
  <p>and</p>
  
  <pre><code>curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
  </code></pre>
  
  <p>in <code>get_data.php</code></p>
  
  <p>It is not working. Cookie file is getting created but second curl is not reading it.
  Is this the right way to do it ? Do I have to read the cookie file seperately and set the header <code>Cookie</code> ? Any help would appreciated. Thanks.</p>