title: Unable to login Google with curl
body: <p>I want to login in google.com with php via <code>curl</code> but i am getting login page again and again.</p>
  
  <p>Here is my code</p>
  
  <pre><code>$ch = curl_init();
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.1    (KHTML, like Gecko) Chrome/21.0.1180.79 Safari/537.1 AlexaToolbar/alxg-3.1");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR);
  curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIEJAR);
  curl_setopt($ch, CURLOPT_HEADER, 0);  
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
  curl_setopt($ch, CURLOPT_TIMEOUT, 120);
  curl_setopt($ch, CURLOPT_URL, 'https://accounts.google.com/ServiceLoginAuth');
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
  $result = curl_exec($ch);
  var_dump($result);
  </code></pre>
  
  <p>Also it is not creating the cookie file </p>
  
  <p>I found this link <a href="https://stackoverflow.com/questions/8991873/login-to-google-with-php-and-curl-cookie-turned-off">Login to Google with PHP and Curl, Cookie turned off?</a> . there is also the same code as mine but also i am unable to login.</p>
  
  <p>What is wrong in this code ?</p>