Get session from curl php


Get session from curl php

我在获得网站的实际会话时遇到了一些麻烦,我需要在以后使用它。

$url="http://blabalbla";
$postdata="pass:123";
curl_setopt($handler, CURLOPT_URL, $url);
curl_setopt($handler, CURLOPT_POST,true);
curl_setopt($handler, CURLOPT_HEADER, 0);
//Le vamos a enviar parámetros posts
curl_setopt($handler, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($handler, CURLOPT_COOKIEJAR, 'cookie.txt');
//Para poder guardar el html
curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
//Para seguir las redirecciones
curl_setopt($handler, CURLOPT_FOLLOWLOCATION, true);
$url_destino=curl_getinfo($handler, CURLINFO_EFFECTIVE_URL);
//Executamos
$response = curl_exec ($handler);
我可以看到会话保存在cookie下的PHPSESSID

看起来像您的会话cookie保存,但没有使用。尝试添加这个选项

curl_setopt($handler, CURLOPT_COOKIEFILE, 'cookie.txt');