cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Time for next round!

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Fri, 19 Aug 2005 23:39:00 +0200 (CEST)

On Fri, 19 Aug 2005, Jeff Pohlmeyer wrote:

> For instance, if I have a file "cookies.one" that contains the line:
> Set-Cookie: SECRET=ForYourEyesOnly; expires=Thu, 01-Jun-2006 19:00:00
> GMT; path=/;
>
> And a file named "cookies.two" that contains:
> Set-Cookie: PUBLIC=InTheTabloids; expires=Thu, 01-Jun-2006 19:00:00 GMT; path=/;
>
> It is not-so-obvious to me that the code below will send the _first_ cookie
> to the _second_ server:
>
> curl_easy_setopt(c, CURLOPT_COOKIEFILE, "cookies.one");
> curl_easy_setopt(c, CURLOPT_URL, "http://www.yahoo.com/");
> curl_easy_perform(c);
> curl_easy_setopt(c, CURLOPT_COOKIEFILE, "cookies.two");
> curl_easy_setopt(c, CURLOPT_URL, "http://www.google.com/");
> curl_easy_perform(c);

Yes, you are right.

- Using the new CURLOPT_COOKIELIST you can in fact flush the known cookies
   in between in case you want that.

- The reason for this dilemms is that HTTP cookies headers without a domain
   set are messy to deal with. When received from a remote server by curl, it
   adds the current domain but when read from a file there is no default domain
   to use and thus it will match all domains.

- It is another reason to use proper cookie files and not HTTP cookie lines!

> Maybe the docs could mention something like: "If this option is used more
> than once, the cookies from subsequent files will be appended to the
> original list."

Done!

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2005-08-19