title: cURL Login to HTTPS site
body: <p>I have been trying to post login credentials to an https site using cURL and PHP with no luck. Everything works fine for unsecured sites but I can't get it with https. I know the headers details that I am posting are correct (although I mocked them up for the sake of this example). Please help.</p>
  
  <pre><code>    &lt;?php
      // Initialize cURL
      $ch = curl_init('https://secured-example.com/auth.asp');
  
      // Enable HTTP POST
      curl_setopt($ch, CURLOPT_POST, 1);
  
      // Use SSL 
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
  
      // Set POST parameters
      curl_setopt($ch, CURLOPT_POSTFIELDS, 'username=myUser&amp;password=myPass');
  
      // Imitate classic browser's behavior - handle cookies
      curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
  
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  
      // Execute 1st request
      $store = curl_exec($ch);
  
      // Set file to download
      curl_setopt($ch, CURLOPT_URL, 'https://secured-example.com/file.pdf');
  
      // Execute 2nd request (file download)
      $content = curl_exec($ch);
  
      curl_close($ch);
  
      ?&gt;
  </code></pre>