title: Reuse cookie cURL PHP
body: <p>I'm trying to make it use the cookie, which is saved, instead of logging in each time the site is visited.</p>
  
  <pre><code>&lt;?php
  $uid = $_GET['uid'];
  $ch = curl_init();
  $cookie_file = dirname(__FILE__) . '/cookie.txt';
  curl_setopt($ch, CURLOPT_URL, "http://www.forum.net/member.php?action=do_login");
  curl_setopt($ch, CURLOPT_REFERER, "http://www.forum.net/member.php?action=login");
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5");
  curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . '/cookie.txt');
  curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookie.txt');
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($ch, CURLOPT_COOKIEFILE, '/cookie.txt');
  curl_setopt($ch, CURLOPT_POSTFIELDS, "username=USERNAME&amp;password=PASSWORD");
  $exec = curl_exec($ch);
  curl_setopt($ch, CURLOPT_URL, "http://www.forum.net/reputation.php?uid=" . $uid . "&amp;page=1");
  $exec = curl_exec($ch);
  echo $exec;
  ?&gt;
  </code></pre>
  
  <p>It won't let me reuse the cookie, for some reason, but instead it just logs me in. The cookie.txt file contains the cookie stuff.</p>