cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: cookie and CURLOPT_COOKIEFILE

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 17 Sep 2003 09:35:46 +0200 (CEST)

On Wed, 17 Sep 2003 jerry_at_oridus.com wrote:

> my purpose of using it is to actually get cookie from server ( from
> "Set-Cookie" in response header ), and set it in subsequent requests. I am
> not trying to read existing cookie from an existing file

Yes, I understand that. You're not the first person to do it either.

> According to tutorial ( see below in
> http://curl.haxx.se/libcurl/c/the-guide.html ), we can approach it by set
> CURLOPT_COOKIEFILE w/ a file which doesn't exist.

I know, I wrote it.

> ****Many times this is enough, and you may not have to save the cookies to
> disk at all.

Correct, and COOKIEFILE has nothing to do with saving, it is about
loading/reading.

> curl_easy_setopt(handle_name, CURLOPT_COOKIEFILE, "" )

Did you even try to do this? AFAICT, this is indeed a working way.

> curl_easy_setopt(handle_name, CURLOPT_COOKIEFILE)

This is not possible to detect and will never be a good way to specify
anything.

> nobody ca 100% guarantee the filename doesn't exist.

I wrote "next to guaranteed" on purpose. Most systems can be very certain a
specific full path name won't exist, or will be zero bytes.

But since sending in a zero-length file name works too, this issue is moot
anyway.

> Certainly it depends on how libcurl searches its existence

libcurl doesn't "search" for the file at all, it tries to read the file name
you give it. Nothing more, nothing less.

> Therefore, I think we can remove "pass file which doesn't exist" from
> document for people who simply want to retrive cookie from server side, not
> existing file in disk.

I don't understand. That's how libcurl currently works, why would we remove
that paragraph from the document?

-- 
 Daniel Stenberg -- curl: been grokking URLs since 1998
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-09-17