1CURLINFO_COOKIELIST(3) curl_easy_getinfo options CURLINFO_COOKIELIST(3)
2
3
4
6 CURLINFO_COOKIELIST - get all known cookies
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_COOKIELIST,
12 struct curl_slist **cookies);
13
15 Pass a pointer to a 'struct curl_slist *' to receive a linked-list of
16 all cookies curl knows (expired ones, too). Don't forget to call
17 curl_slist_free_all(3) on the list after it has been used. If there
18 are no cookies (cookies for the handle have not been enabled or simply
19 none have been received) 'struct curl_slist *' will be set to point to
20 NULL.
21
22 Since 7.43.0 cookies that were imported in the Set-Cookie format with‐
23 out a domain name are not exported by this option.
24
26 HTTP(S)
27
29 CURL *curl = curl_easy_init();
30 if(curl) {
31 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
32
33 /* enable the cookie engine */
34 curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
35
36 res = curl_easy_perform(curl);
37
38 if(!res) {
39 /* extract all known cookies */
40 struct curl_slist *cookies = NULL;
41 res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
42 if(!res && cookies) {
43 /* a linked list of cookies in cookie file format */
44 struct curl_slist *each = cookies;
45 while(each) {
46 printf("%s\n", each->data);
47 each = each->next;
48 }
49 /* we must free these cookies when we're done */
50 curl_slist_free_all(cookies);
51 }
52 }
53 curl_easy_cleanup(curl);
54 }
55
57 Added in 7.14.1
58
60 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
61 if not.
62
64 curl_easy_getinfo(3), curl_easy_setopt(3), CURLOPT_COOKIELIST(3),
65
66
67
68libcurl 7.76.1 November 04, 2020 CURLINFO_COOKIELIST(3)