cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Question about cookies

From: Ralph Mitchell <ralphmitchell_at_gmail.com>
Date: Tue, 15 Sep 2009 22:38:14 -0500

>
> On Sep 11, 2009, at 2:37 PM, Ralph Mitchell wrote:
>
> On Fri, Sep 11, 2009 at 1:18 PM, Jonathan Wallace <
> jwallace_at_livetechnology.com> wrote:
>
>> Is it possible to get a list of cookies from the return header so that I
>> can tokenize it and record them in my application. Currently I'm using a
>> CURLOPT_DEBUGFUNCTION and CURLOPT_VERBOSE to retrieve the header and
>> tokenize and I'm wondering if there is a more elegant and faster way to do
>> this?
>>
>
> How about CURLINFO_COOKIELIST?? That gets you a linked list of all cookies
> curl knows about.
>
> Ralph Mitchell
>
> On Fri, Sep 11, 2009 at 1:51 PM, Jonathan Wallace <
jwallace_at_livetechnology.com> wrote:

> That looks promising, but how do I use it? I see two public methods on the
> curl_slist struct, data and next. How do I get the cookie's name and data
> out of it?
>
>
I wouldn't know a public method if it jumped up and bit me. It's been a
while since I did any C, but what I see in the curl.h include file is:

   struct curl_slist {
      char *data;
      struct curl_slist *next;
   };

so I'm thinking if you have a pointer 'p' to that struct, then after calling
curl_easy_getinfo, you'd pick up your first cookie from p->data. To get to
the next cookie, something like p=p->next gets you your next cookie.
 Lather, rinse, repeat until p->next is null. Or something like that...

Like I said, it's been awhile, so don't flame me on syntax... :)

Ralph Mitchell
Received on 2009-09-16