php cookic过期还能拿到,php – 使用cURL会话Cookie过期时

根据

mozilla.org:

session cookie […] is deleted when the client shuts down, because it didn’t specify an Expires or Max-Age directive. However, web browsers may use session restoring, which makes most session cookies permanent, as if the browser was never closed.

By default, libcurl always stores and loads all cookies, independent if they are session cookies or not. Session cookies are cookies without expiry date and they are meant to be alive and existing for this “session” only.

如果您将cookie保存在指定的文件中

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://stackoverflow.com');

curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookie.txt');

$output = curl_exec($ch);

curl_close($ch);

然后,从客户端的角度来看,只要使用正确的cookie设置CURLOPT_COOKIEJAR,会话就会处于活动状态.这是您的脚本的选择.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值