GNURLINFO_COOKIELIST(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸͺ NAME πŸͺ

bestie, welcome to GNURLINFO_COOKIELIST(3). The main character here is CURLINFO_COOKIELIST β€” get all known cookies. that's the whole assignment, and it ate. πŸͺ✨

✨ SYNOPSIS ✨

#include <gnurl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_COOKIELIST,
                           struct curl_slist **cookies);

πŸ’… DESCRIPTION πŸ’…

okay so you pass a pointer to a struct curl_slist *, and it receives a linked-list of all the cookies curl knows about β€” expired ones too, no filter, no cap. πŸ’€

and like, don't forget to call curl_slist_free_all(3) on the list after it has been used. free your cookies, bestie. 🫢

if there are no cookies (cookies for the handle have not been enabled or simply none have been received), the struct curl_slist * will be set to point to NULL. lowkey peaceful.

since 7.43.0, cookies that were imported in the Set-Cookie format without a domain name are not exported by this option. iykyk. πŸ“

🌐 PROTOCOLS 🌐

HTTP(S) β€” that's the vibe. 🌈

πŸ§ͺ EXAMPLE πŸ§ͺ

here's the code, bestie, copied exactly so you don't have to squint:

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");

  /* enable the cookie engine */
  curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");

  res = curl_easy_perform(curl);

  if(!res) {
    /* extract all known cookies */
    struct curl_slist *cookies = NULL;
    res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
    if(!res && cookies) {
      /* a linked list of cookies in cookie file format */
      struct curl_slist *each = cookies;
      while(each) {
        printf("%s\n", each->data);
        each = each->next;
      }
      /* we must free these cookies when we're done */
      curl_slist_free_all(cookies);
    }
  }
  curl_easy_cleanup(curl);
}

πŸ•°οΈ AVAILABILITY πŸ•°οΈ

added in 7.14.1. periodt. πŸ’…

πŸ” RETURN VALUE πŸ”

  • returns CURLE_OK if the option is supported.
  • returns CURLE_UNKNOWN_OPTION if not.

πŸ‘€ SEE ALSO πŸ‘€

the little squad to check out: curl_easy_getinfo(3), curl_easy_setopt(3), CURLOPT_COOKIELIST(3), β€” yes bestie, that trailing comma is right there in the original, i don't make the rules. πŸŽ€


made with libcurl 7.44.0, dated 1 Sep 2015 β€” mwah, love u, go get those cookies πŸͺπŸ’–

πŸ“¦ where this page comes from