curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: Use of cookies

From: Mac-Fly via curl-library <curl-library_at_cool.haxx.se>
Date: Mon, 06 Apr 2020 18:41:27 +0200

Dear Daniel,

let me answer hereby:
> *ever growing* ? What exactly does that mean.
It meant although I reset in between perform() calls the cookies of the old call remain in memory. E.g.: perform() on site A , clean-up, perform() on site B would have had the cookies of both: A and B. Doing perform() on site A again does not change the list (cookies of site A are not duplicated).

> Without details [...]
I understand that and I was compiling a minimal example for you. While doing so I found the error!!!

In the libCURL example (cookies_interface.c), you call:
curl_easy_setopt([CURL_handle], CURLOPT_COOKIELIST, cookie);
...where "cookie" is a char buffer. What I did was something like:
std::string cookie = "...";
curl_easy_setopt([CURL_handle], CURLOPT_COOKIELIST, cookie.c_str());
...which does not raise an error but does also not apply the cookie. So it really must be a buffer you provide to the function.

Changing into:
char cookie_buffer[256]; snprintf(cookie_buffer, [...]);
curl_easy_setopt([CURL_handle], CURLOPT_COOKIELIST, cookie_buffer);
...made it work!
Problem solved. So, I put it here for other that might trap into th same issue. Settings cookies must be done through buffers. Period.

Thank you anyway for the time you took and of course for libCURL! ;-)

Best regards,
Morten.

----- Original Message -----
From: Daniel Stenberg <daniel_at_haxx.se>
To: Mac-Fly via curl-library <curl-library_at_cool.haxx.se>
Cc: Mac-Fly <mac-fly_at_gmx.net>
Date: Mon, 6 Apr 2020 15:08:03 +0200 (CEST)
Subject: Re: Use of cookies

> On Mon, 6 Apr 2020, Mac-Fly via curl-library wrote:
>
> > I call:
> > - curl_easy_setopt([CURL_handle], CURLOPT_COOKIEFILE, "");
> > - curl_easy_setopt([CURL_handle], CURLOPT_COOKIELIST, "ALL");
> > - curl_easy_setopt([CURL_handle], CURLOPT_COOKIELIST, cookie);
> > - curl_easy_perform([CURL_handle]); >> to launch the call
> > - curl_easy_getinfo([CURL_handle], CURLINFO_COOKIELIST, &cookie_list);
>
> If you temporary remove the 'curl_easy_perform' you can see if libcurl parsed
> your incoming cookies as you expected it to.
>
> > - the list of cookies is ever growing and not being reset
>
> *ever growing* ? What exactly does that mean. Surely there can't be any more
> than the ones you set plus the ones the site sets? How does it keep growing?
>
> > - it never contains the cookies I set.
>
> Without details (like exact contents of what is passed in to curl and server
> response headers) nor a way to reproduce, it is very hard for us to guess what
> the problem is.
>
> --
>
> / daniel.haxx.se | Commercial curl support up to 24x7 is available!
> | Private help, bug fixes, support, ports, new features
> | https://www.wolfssl.com/contact/
>

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-04-06