how to maintain session in cURL in php?
- by newbie programmer
how can we maintain session in cURL?
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.
here is my code that used to login to the site using cURL
<?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&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);
?>