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:
CURLOPT_COOKIELIST(3)πͺcurl_easy_getinfo(3)β¨curl_easy_setopt(3)π
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
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms