cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: COOKIEJAR & COOKIEFILE & modifying outgoing cookies

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Thu, 17 Mar 2005 08:49:18 +0100 (CET)

On Wed, 16 Mar 2005, Dave wrote:

> JAR=writeonly, FILE=readonly?
>
> Is this a fair assumption?

Yes. And both activates the cookie engine in libcurl when used, so both will
make libcurl record cookies and send matching ones on subsequent requests
(like when following a redirect etc).

> I then wonder if I should ALWAYS use both JAR and FILE together in order to
> store and forward all cookies..

You can do that.

> or could I use JAR initially during a login/session and use FILE
> subsequently to restablish a session (if server permits).

For the first request there's no point in passing the FILE if you don't
already have valid cookies.

For the subsequent requests there is a point to keep using the JAR option as
well, since servers are known to update cookie contents while you move around
on the site.

> I receive some cookies and store in a JAR..one of those particular cookies
> needs to be a little different than what is handed to me and/or changing
> expiration. I have been trying to figure out how to rewrite that particular
> cookie on it's way back out toward the server so I don't have to bother
> editing the cookie file.

libcurl lacks a proper cookie API[*], so this is not easily done. People
generally edit the cooikejar file between invokes to achieve this.

[*] = http://curl.haxx.se/dev/COOKIES-new is the most recent suggested API
       for how libcurl could offer an API that would allow apps to fiddle with
       cookies without having to bother with files etc.

       No one is currently working on this, but it pops up and gets discussed
       every once in a while. I would love to see it added.

-- 
      Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2005-03-17