PDA

View Full Version : CURL Not Saving Sessions



hemi519
04-19-2013, 07:16 AM
Hi All,


I am integrating two websites with one login. One website is done in Core PHP(movies website) and the other one is SocialEngine(Zend, Social Networking Site). For both websites database is same. Now i want to login from movie website and should be able to use Social Networking Website aslo.

I started using CURL for this process. With below code i am able to login with same credentials and i am getting home page of my SocialNetworking Site. Problem is, when i click on any other link relating to SocialNetworking site, it's taking back to Login for that site. But still i am active in Movie Website.




$random = rand(10,100000000000000000);
$id = "user";
$pw = "user";

$fields = array('email'=>$id, 'password'=>$pw,'return_url'=>"64-L3NlL2luZGV4LnBocC9ncm91cHM=");

$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // Allow redirection
curl_setopt($ch, CURLOPT_COOKIEFILE, "/var/www/se/temporary/session/sess_".$random);
curl_setopt($ch, CURLOPT_COOKIEJAR, "/var/www/se/temporary/session/sess_".$random);
curl_setopt($ch, CURLOPT_URL, "http://localhost/test/index.php/login");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_exec($ch);




How can i save session for total website with CURl? Is this way correct or is thr any other way to do this?