CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_COOKIELIST,
struct curl_slist **cookies);
Since 7.43.0 cookies that were imported in the Set-Cookie format without a domain name are not exported by this option.
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://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);
}