1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLINFO_COOKIELIST 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_COOKIELIST (3) 9 - curl_easy_getinfo (3) 10 - curl_easy_setopt (3) 11Protocol: 12 - HTTP 13--- 14 15# NAME 16 17CURLINFO_COOKIELIST - get all known cookies 18 19# SYNOPSIS 20 21~~~c 22#include <curl/curl.h> 23 24CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_COOKIELIST, 25 struct curl_slist **cookies); 26~~~ 27 28# DESCRIPTION 29 30Pass a pointer to a 'struct curl_slist *' to receive a linked-list of all 31cookies curl knows (expired ones, too). Do not forget to call 32curl_slist_free_all(3) on the list after it has been used. If there are no 33cookies (cookies for the handle have not been enabled or simply none have been 34received) the 'struct curl_slist *' is made a NULL pointer. 35 36Since 7.43.0 cookies that were imported in the Set-Cookie format without a 37domain name are not exported by this option. 38 39# EXAMPLE 40 41~~~c 42int main(void) 43{ 44 CURL *curl = curl_easy_init(); 45 if(curl) { 46 CURLcode res; 47 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 48 49 /* enable the cookie engine */ 50 curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); 51 52 res = curl_easy_perform(curl); 53 54 if(!res) { 55 /* extract all known cookies */ 56 struct curl_slist *cookies = NULL; 57 res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies); 58 if(!res && cookies) { 59 /* a linked list of cookies in cookie file format */ 60 struct curl_slist *each = cookies; 61 while(each) { 62 printf("%s\n", each->data); 63 each = each->next; 64 } 65 /* we must free these cookies when we are done */ 66 curl_slist_free_all(cookies); 67 } 68 } 69 curl_easy_cleanup(curl); 70 } 71} 72~~~ 73 74# AVAILABILITY 75 76Added in 7.14.1 77 78# RETURN VALUE 79 80Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 81