GNURLINFO_COOKIELIST(3)
πͺ 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_OKif the option is supported. - returns
CURLE_UNKNOWN_OPTIONif 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
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms