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

curl-and-php

Re: COOKIEJAR & COOKIEFILE & modifying outgoing cookies

From: Dave <dave_at_cc0.net>
Date: Thu, 17 Mar 2005 00:03:53 -0800

Thank you Daniel,

You seemed to answer every single one of my questions effectively.

I didn't pose the issue with writing of the JAR as a question...but I am
curious if you have any clues as to why it may be occuring.

Basically I want the JAR to be on disk and flushed as soon as possible so I
can modify, but it looks like it doesn't get written to disk until another
curl_init into the same PHP var clobbers the previous. I tried using various
setopts such as FORBID_REUSE and FRESH_CONNECT but didn't seem to help.

Any ideas?

Thanks!

-Dave

> 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