title: how to maintain session in cURL in php?
body: <p>how can we maintain session in cURL?</p>
  
  <p>i'am having a code the sends login details of a site and logs in successfully
  i need to get the session maintained at the site to continue.</p>
  
  <p>here is my code that used to login to the site using cURL</p>
  
  <pre><code>  &lt;?php  
          $socket = curl_init();
          curl_setopt($socket, CURLOPT_URL, "http://www.XXXXXXX.com");
      curl_setopt($socket, CURLOPT_REFERER, "http://www.XXXXXXX.com");
      curl_setopt($socket, CURLOPT_POST, true);
      curl_setopt($socket, CURLOPT_USERAGENT, $agent);
      curl_setopt($socket, CURLOPT_POSTFIELDS, "form_logusername=XXXXX&amp;form_logpassword=XXXXX");
      curl_setopt($socket, CURLOPT_COOKIESESSION, true);
      curl_setopt($socket, CURLOPT_COOKIEJAR, "cookies.txt");
      curl_setopt($socket, CURLOPT_COOKIEFILE, "cookies.txt");
      $data = curl_exec($socket);
      curl_close($socket); 
     ?&gt;
  </code></pre>