Home >Backend Development >PHP Tutorial >curl cookie file cannot be saved

curl cookie file cannot be saved

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-09-01 00:20:141640browse

$curl = curl_init();

<code>    $cookie_jar = dirname(__FILE__)."/tmp/123.txt"; //tempnam--建立一个具有唯一文件名的文件
    curl_setopt($curl, CURLOPT_URL,'XX');//这里写上处理登录的界面
    curl_setopt($curl, CURLOPT_POST, 1); //post提交数据
    curl_setopt($curl, CURLOPT_POSTFIELDS, $params);//传递数据
    curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_jar);//把返回来的cookie信息保存在$cookie_jar文件中
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);//设定返回的数据是否自动显示
    curl_setopt($curl, CURLOPT_HEADER, false);//设定是否显示头信息
    curl_setopt($curl, CURLOPT_NOBODY, false);//设定是否输出页面内容
    $return = curl_exec($curl);//返回结果
    curl_close($curl); //关闭*/
    
    
    为什么这样查看的cookie文件是空啊?</code>

Reply content:

$curl = curl_init();

<code>    $cookie_jar = dirname(__FILE__)."/tmp/123.txt"; //tempnam--建立一个具有唯一文件名的文件
    curl_setopt($curl, CURLOPT_URL,'XX');//这里写上处理登录的界面
    curl_setopt($curl, CURLOPT_POST, 1); //post提交数据
    curl_setopt($curl, CURLOPT_POSTFIELDS, $params);//传递数据
    curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_jar);//把返回来的cookie信息保存在$cookie_jar文件中
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);//设定返回的数据是否自动显示
    curl_setopt($curl, CURLOPT_HEADER, false);//设定是否显示头信息
    curl_setopt($curl, CURLOPT_NOBODY, false);//设定是否输出页面内容
    $return = curl_exec($curl);//返回结果
    curl_close($curl); //关闭*/
    
    
    为什么这样查看的cookie文件是空啊?</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn