【问题标题】:PHP Curl save sessionPHP Curl 保存会话
【发布时间】:2014-05-25 07:20:46
【问题描述】:

这个站点是 HTTPS,我想要打开第一页、保存会话而不是打开第二页的 CURL。这可能吗?第一页自动生成语言会话,我需要这个会话。没有这个第二页会出错。

错误:

[8] 未定义索引:lang 文件:/var/www/spa-public/public_html/lib/controller.php - 行:8 [2] require_once(lang/.pack.php):无法打开流:没有这样的文件或目录 文件:/var/www/spa-public/public_html/lib/controller.php - 行:8

我的脚本:

<?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;

?>

【问题讨论】:

    标签: php session curl


    【解决方案1】:

    将这些字段添加到 curl。然后调用第一个然后使用相同的 cookie 调用第二个

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-12
      • 2014-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多