cURL Cookie否定Cookie过期 [英] cURL cookie negative cookie expire

查看:162
本文介绍了cURL Cookie否定Cookie过期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有cURL的cookies问题。



遇到问题后,我打开了详细功能,并确定cURL设置他们负过期日期,即使服务器发送正数日期。 / p>

示例:

  *添加了cookie _c_sess =test for domain test.com,path /,expire -1630024962 
< Set-Cookie:_c_sess =test; Domain = test.com; HttpOnly; expires = Mon,26-Mar-2012 14:52:47 GMT; Max-Age = 1332773567; Path = /

正如你可以看到expires和max-age都是正数,但cURL设置过期负值。



有人有想法?



编辑:



这里是我使用的php代码。

  $ ch = curl_init 
curl_setopt($ ch,CURLOPT_URL,http://site.com/);
curl_setopt($ ch,CURLOPT_USERAGENT,'Mozilla / 5.0(Windows NT 6.1; rv:11.0)Gecko / 20100101 Firefox / 11.0');
curl_setopt($ ch,CURLOPT_COOKIEJAR,$ cookiepath);
curl_setopt($ ch,CURLOPT_COOKIEFILE,$ cookiepath);
curl_setopt($ ch,CURLOPT_HEADER,1);
curl_setopt($ ch,CURLOPT_VERBOSE,1);
curl_setopt($ ch,CURLOPT_STDERR,$ f);
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ ch,CURLOPT_SSL_VERIFYPEER,0);
$ data = curl_exec($ ch);

来自cookie jar的数据:

 #HttpOnly_.test.com TRUE / FALSE -1630016318 _test_sesstest


解决方案

也许这与 Curl无法正确识别Cookie中的过期值 - 由于32位有符号整数值的限制,您的计算机上遇到问题。


I have problems with cookies with cURL.

After problems I turned on verbose function and figured out cURL sets them negative expire date even if server sends positive date.

Example:

* Added cookie _c_sess=""test"" for domain test.com, path /, expire -1630024962
< Set-Cookie: _c_sess="test"; Domain=test.com; HttpOnly; expires=Mon, 26-Mar-2012 14:52:47 GMT; Max-Age=1332773567; Path=/

As you can see both expires and max-age are positive, but cURL sets expire to negative value.

Somebody has idea?

EDIT:

Here is php code I use.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://site.com/");
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20100101 Firefox/11.0');
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiepath);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiepath);
curl_setopt($ch, CURLOPT_HEADER  ,1);
curl_setopt($ch, CURLOPT_VERBOSE  ,1);
curl_setopt($ch, CURLOPT_STDERR  ,$f);
curl_setopt($ch, CURLOPT_RETURNTRANSFER  ,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION  ,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$data = curl_exec($ch);

Data from cookie jar:

#HttpOnly_.test.com TRUE    /   FALSE   -1630016318 _test_sess  "test"

解决方案

Maybe it's the same issue as Curl doesn't recognize expires value in cookie correctly - "You are experiencing an issue on your computer because of the limits of 32 bit signed integer values."

这篇关于cURL Cookie否定Cookie过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆