title: Script for secure cPanel login with PHP
body: <p>Since recently, cPanel has changed the way that it logs in.</p>
  
  <p>Before login, the url is : <strong>https://accessurl:2083/</strong></p>
  
  <p>After login : <strong>https://accessurl:2083/cpsessXXXX/frontend/x3/index.html?post_login=89711792346495</strong></p>
  
  <p>You will note the <strong>cpsessXXXX</strong> embedded in the url.</p>
  
  <p>And the page to access AWSTATS is :<strong>https://accessurl:2083/cpsessXXXX/awstats.pl?config=domain_name&amp;ssl=&amp;lang=en</strong></p>
  
  <p>I have tried the following PHP code</p>
  
  <pre><code>$username = 'xxx';
  $password = 'xxx';
  $loginUrl = 'https://&lt;accessurl&gt;';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $loginUrl);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, 'user='.$username.'&amp;pass='.$password);
  curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_PORT,2083);
  $store = curl_exec($ch);
  curl_close($ch);
  </code></pre>
  
  <p>When I step through the code, the value of <strong>$store</strong> is FALSE, meaning that the login process failed. </p>
  
  <p>The only reference that I found on the web to a similar problem is
  at <a href="http://blog.mcfang.com/" rel="nofollow">http://blog.mcfang.com/</a> in the March 28 entry.</p>
  
  <p>I was hoping that cookies.txt would have the cpsessXXXX info, but no file is created.</p>
  
  <p>Thanks for any help</p>