简体   繁体   中英

PHP Curl save session

This site is HTTPS and I want CURL which open first page, save sessions and than open second page. Is this possible? First page generate language session automatically and I need this session. Without this second page get error.

Error:

[8] Undefined index: lang File: /var/www/spa-public/public_html/lib/controller.php - Line:8 [2] require_once(lang/.pack.php): failed to open stream: No such file or directory File: /var/www/spa-public/public_html/lib/controller.php - Line:8

My Script:

<?php
$postfields = array('lang'=>'ge');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'SECOND_URL');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($ch);

echo $result;

?>

Add these fields to curl. then call first one then using same cookie call second one

curl_setopt($ch, CURLOPT_COOKIEJAR, "COOKIE.txt"); 
curl_setopt($ch, CURLOPT_COOKIEFILE, "COOKIE.txt"); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM