1CURLOPT_COOKIESESSION(3) curl_easy_setopt options CURLOPT_COOKIESESSION(3)
2
3
4
6 CURLOPT_COOKIESESSION - start a new cookie session
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIESESSION, long init);
12
14 Pass a long set to 1 to mark this as a new cookie "session". It will
15 force libcurl to ignore all cookies it is about to load that are "ses‐
16 sion cookies" from the previous session. By default, libcurl always
17 stores and loads all cookies, independent if they are session cookies
18 or not. Session cookies are cookies without expiry date and they are
19 meant to be alive and existing for this "session" only.
20
21 A "session" is usually defined in browser land for as long as you have
22 your browser up, more or less.
23
25 0
26
28 HTTP
29
31 CURL *curl = curl_easy_init();
32 if(curl) {
33 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
34
35 /* new "session", do not load session cookies */
36 curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1L);
37
38 /* get the (non session) cookies from this file */
39 curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/tmp/cookies.txt");
40
41 ret = curl_easy_perform(curl);
42
43 curl_easy_cleanup(curl);
44 }
45
47 Along with HTTP
48
50 Returns CURLE_OK
51
53 CURLOPT_COOKIEFILE(3), CURLOPT_COOKIE(3),
54
55
56
57libcurl 7.82.0 November 26, 2021 CURLOPT_COOKIESESSION(3)