title: Download a file via CURL with Cookies using php
body: <p>I need to POST cookies.txt then download a page to a text file using CURL. This is my FGC example but apparently FGC is bad at cookies so I need CURL.</p>
  
  <pre><code>&lt;?php
      $file = file('source\1.txt');
      foreach ($file as $link)
      {
          $link       = trim($link);
          $link2      = "http://site-that.com/authenticates?={$link}";
          $downloaded = file_get_contents($link2);
          $myFile     = "parsed/$link" . ".txt";
          $fh = fopen($myFile, 'a') or die('Cannot open file');
          fwrite($fh, $downloaded);
      }
      $timestamp = time();
      rename('source\1.txt', "source/done/done-{$timestamp}.txt");
      echo 'Finished';
  </code></pre>
  
  <p>Any ideas? Code examples would be extremely appreciated. A simple example that does this to like google.com would be great Also, if you have another way to do this that's faster, please post!</p>