title: Multiple cURL actions, same session
body: <p>First of all I'm aware of curl_multi_init but it doesn't exactly do what I need, to my knowledge.</p>
  
  <p>Im downloading files behind a login, so </p>
  
  <p>a) Need to login
  b) Download image(s)</p>
  
  <p>Here is what I currently have</p>
  
  <pre><code>$login_url = 'https://us.test.com/Member/Login';
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,$login_url);
  curl_setopt($ch, CURLOPT_POSTFIELDS, 'login='.$this-&gt;username.'&amp;password='.$this-&gt;userpass.'&amp;signin=1&amp;login_referer=none&amp;remember_me=1');
  curl_setopt($ch, CURLOPT_FAILONERROR,1);  
  curl_setopt($ch, CURLOPT_COOKIEFILE, $_SERVER['DOCUMENT_ROOT'].'/test/cookie.txt');
  curl_setopt($ch, CURLOPT_COOKIEJAR, $_SERVER['DOCUMENT_ROOT'].'/test/cookie.txt');  
  curl_setopt($ch, CURLOPT_COOKIESESSION, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch, CURLOPT_POST, true);   
  curl_exec($ch);
  
  //Grab and Write the image
  $image = file_get_contents($image_url); 
  $f = fopen($_SERVER['DOCUMENT_ROOT'].'/test/uploads/'.$id.'.jpg', 'w');
  fwrite($f, $image);
  fclose($f);  
  
  
  curl_close($ch);
  </code></pre>
  
  <p>Anything helps, much appreciated.</p>