title: Curl doesn't recognize expires value in cookie correctly
body: <p>I'm trying to perfom a log-in on pinterest.com with curl.  I got the following request-response-flow:</p>
  
  <ol>
  <li>GET-Request the login form and scrape hidden fields (csrftoken)</li>
  <li>POST-Request login credentials (mail and pw) and scraped csrftoken</li>
  <li>Receive Session Cookie for login</li>
  </ol>
  
  <p>Using Curl, I can see the following Headers being sent and received:</p>
  
  <pre><code> GET /login/?next=%2F HTTP/1.1
   User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2
   Host: pinterest.com
   Referer:
   Accept: text/html,application/xhtml+xml,application/xml,*/*
   Accept-Language: de-de,en-us
   Connection: keep-alive
  
   HTTP/1.1 200 OK
   Content-Type: text/html; charset=utf-8
   Date: Tue, 10 Apr 2012 15:03:24 GMT
   ETag: "45d6a85f0ede46f13f4fc751842ce5b7"
   Server: nginx/0.8.54
   Set-Cookie: csrftoken=dec6cb66064f318790c6d51e3f3a9612; Max-Age=31449600; Path=/
   Set-Cookie: _pinterest_sess="eJyryMwNcTXOdtI3zXcKNq0qznIxyXVxK/KqSsy3tY8vycxNtfUN8a3yc3E09nXxLPdztLVVK04tLs5MsfXNAopVpVf6VnlW+Qba2gIAuqgZIg=="; Domain=pinterest.com; HttpOnly; expires=Tue, 17-Apr-2012 15:03:24 GMT; Max-Age=1334675004; Path=/
   Vary: Cookie, Accept-Encoding
   Content-Length: 4496
   Connection: keep-alive
  </code></pre>
  
  <p>So after step 1, the two cookies csrftoken and _pinterest_sess are set. But a look in the cookiejar file (I use CURLOPT_COOKIEFILE and CURLOPT_COOKIEJAR to let curl handle the cookie processing) shows the following:</p>
  
  <pre><code>   # Netscape HTTP Cookie File
     # http://curl.haxx.se/rfc/cookie_spec.html
     # This file was generated by libcurl! Edit at your own risk.
  
     pinterest.com        FALSE        /        FALSE        1365519805        csrftoken        dec6cb66064f318790c6d51e3f3a9612
     #HttpOnly_.pinterest.com        TRUE        /        FALSE        -1626222087        _pinterest_sess        "eJyryMwNcTXOdtI3zXcKNq0qznIxyXVxK/KqSsy3tY8vycxNtfUN8a3yc3E09nXxLPdztLVVK04tLs5MsfXNAopVpVf6VnlW+Qba2gIAuqgZIg=="
  </code></pre>
  
  <p>First thing to note is the #HttpOnly_ in preceding the _pinterest_sess cookie line. I just assume that curl handles that just fine. But looking further, one can see that a negative value is set as expiration date: -1626222087</p>
  
  <p>I don't know where that's coming from, because the cookie is set with "expires=Tue, 17-Apr-2012 15:03:24 GMT" (which is about 7 days in the future, counting from today).</p>
  
  <p>On the next request, the _pinterest_sess cookie won't be set by curl:</p>
  
  <pre><code> POST /login/?next=%2F HTTP/1.1
   User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2
   Host: pinterest.com
   Referer: https://pinterest.com/login/?next=%2F
   Cookie: csrftoken=dec6cb66064f318790c6d51e3f3a9612
   Accept: text/html,application/xhtml+xml,application/xml,*/*
   Accept-Language: de-de,en-us
   Connection: keep-alive
   Content-Length: 123
   Content-Type: application/x-www-form-urlencoded
  
   HTTP/1.1 302 FOUND
   Content-Type: text/html; charset=utf-8
   Date: Tue, 10 Apr 2012 15:05:26 GMT
   ETag: "d41d8cd98f00b204e9800998ecf8427e"
   Location: http://pinterest.com/
   Server: nginx/0.8.54
   Set-Cookie: _pinterest_sess="eJzLcssPCy4NTclIjvAOrjQzyywoCChISgvLDi+2tY9PrSjILEottvUN8a3yc4k09gtxrfRLt7VVK04tLs5MAYonV/qGeFb4ZkWW+4LES4tTi+KBEv4u6UZ+WYEmvlm+QOxZ6R/iWOEbEmgLAKNfJps="; Domain=pinterest.com; HttpOnly; expires=Tue, 17-Apr-2012 15:05:26 GMT; Max-Age=1334675126; Path=/
   Vary: Cookie
   Content-Length: 0
   Connection: keep-alive
  </code></pre>
  
  <p>In the response, another _pinterest_sess cookie is set since curl didn't send the last one. </p>
  
  <p>Currently, I don't know if I'm doing something wrong or if curl just isn't able to parse the expires value in the cookie correctly.</p>
  
  <p>Any help would be greatly appreciated :)</p>
  
  <p>// edit
  One more thing: 
  According to <a href="http://opensource.apple.com/source/curl/curl-57/curl/lib/cookie.c" rel="nofollow">http://opensource.apple.com/source/curl/curl-57/curl/lib/cookie.c</a> the function curl_getdate() is used to extract the date. The documentation on that function lists some examples (<a href="http://curl.haxx.se/libcurl/c/curl_getdate.html" rel="nofollow">http://curl.haxx.se/libcurl/c/curl_getdate.html</a>):</p>
  
  <ul>
  <li>Sun, 06 Nov 1994 08:49:37 GMT </li>
  <li>Sunday, 06-Nov-94 08:49:37 GMT </li>
  <li>Sun Nov 6 08:49:37 1994 </li>
  <li>06 Nov 1994 08:49:37 GMT </li>
  <li>06-Nov-94 08:49:37 GMT </li>
  <li>Nov 6 08:49:37 1994 </li>
  <li>06 Nov 1994 08:49:37 </li>
  <li>06-Nov-94 08:49:37 </li>
  <li>1994 Nov 6 08:49:37 GMT </li>
  <li>08:49:37 06-Nov-94 </li>
  <li>Sunday 94 6 Nov 08:49:37 </li>
  <li>1994 Nov 6 </li>
  <li>06-Nov-94 </li>
  <li>Sun Nov 6 94 </li>
  <li>1994.Nov.6 </li>
  <li>Sun/Nov/6/94/GMT </li>
  <li>Sun, 06 Nov 1994 08:49:37 CET </li>
  <li>06 Nov 1994 08:49:37 EST </li>
  <li>Sun, 12 Sep 2004 15:05:58 -0700 </li>
  <li>Sat, 11 Sep 2004 21:32:11 +0200 </li>
  <li>20040912 15:05:58 -0700 </li>
  <li>20040911 +0200</li>
  </ul>
  
  <p>None of them matches the above mentioned expires date "Tue, 17-Apr-2012 15:03:24 GMT" because all examples with hyphens only use 2-digit-years..</p>