CURLINFO_COOKIELIST(3)

πŸͺ CURLINFO_COOKIELIST πŸ’…

okay so this page is from the Library Functions Manual, and it's literally about cookies, which is iconic. πŸͺ✨ no cap, this is the one that gives you all the cookies curl knows about.


✨ NAME ✨

CURLINFO_COOKIELIST - all known cookies πŸͺπŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

okay bestie, here's the exact signature, fr fr:

       #include <curl/curl.h>

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

πŸ’– DESCRIPTION πŸ’–

okay so here's the tea: you pass a pointer to a struct curl_slist * to receive a linked-list of all cookies curl knows (expired ones, too) β€” no cap. πŸͺ

⚠️ bestie, do not forget to call curl_slist_free_all(3) on the list after it has been used, or you'll be leaking memory and that's not the vibe. πŸ’…

if there are no cookies (cookies for the handle have not been enabled or simply none have been received) the struct curl_slist * is made a NULL pointer. so yeah, it's giving nothing. πŸ™ˆ

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 🌈

This functionality affects http only 🌸


✨ EXAMPLE ✨

okay so here's a whole example, it's literally giving main character energy πŸ‘‘:

       int main(void)
       {
         CURL *curl = curl_easy_init();
         if(curl) {
           CURLcode result;
           curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");

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

           result = curl_easy_perform(curl);

           if(!result) {
             /* extract all known cookies */
             struct curl_slist *cookies = NULL;
             result = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
             if(!result && 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 are done */
               curl_slist_free_all(cookies);
             }
           }
           curl_easy_cleanup(curl);
         }
       }

πŸ¦‹ AVAILABILITY πŸ¦‹

Added in curl 7.14.1 ✨


πŸ’œ RETURN VALUE πŸ’œ

curl_easy_getinfo(3) returns a CURLcode indicating success or error. 😌

CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3). so like, if it's not zero, something went wrong, bestie. πŸ’€


πŸŽ€ SEE ALSO πŸŽ€

go look at these besties:


xoxo, your favorite Unix bestie πŸ’– β€” this page is from libcurl, dated 2026-10-12, and the manual is CURLINFO_COOKIELIST(3). slay. πŸ’…

πŸ“¦ where this page comes from