cURL cookie negative cookie expire

Posted by Joe Doe on Stack Overflow See other posts from Stack Overflow or by Joe Doe
Published on 2012-03-19T15:11:19Z Indexed on 2012/04/12 11:29 UTC
Read the original article Hit count: 202

Filed under:
|

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"

© Stack Overflow or respective owner

Related posts about php

Related posts about curl