Jump to content

Problem with setting the session when using cURL


Gruzin

Recommended Posts

Hey,

 

I'm trying to log in using cURL and I need to set the session, but  the cookie.txt is always emty and session is nerver set. hope someone can help...

 

here is my code:

 

<?php
// INIT CURL
$ch = curl_init();

// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, 'http://localhost/parts/padmin/login.php');

// ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1);

// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'user=gio&pass=gio');

// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES

curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');


curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, TRUE);

// EXECUTE 1st REQUEST (FORM LOGIN)
$store = curl_exec ($ch);



// CLOSE CURL
curl_close ($ch); 


?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.