1

i want to login a web site with curl php an i can it but no active login and when i call another php file for request this site I see that no avtive login I want save login information for use it in the other php file but iam not slove it.

a.php:

this code is ok and i can login site but when call b.php login session is lose

=====================

b.php:

I want to do when call a.php and login to site when call b.php it is work ok and not lose login seesion ( a.php )

Behnam.sh
  • 21
  • 5

1 Answers1

0

a.php should at least contain:

$cookies = tempnam('/tmp','cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies); 

b.php should at least contain:

$cookies = tempnam('/tmp','cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies);

CURLOPT_COOKIEJAR is the path where curl will write the cookies from the http response.

CURLOPT_COOKIEFILE is the path where curl will read the cookies for the http request.

François Huppé
  • 2,006
  • 1
  • 6
  • 15