CURLOPT_COOKIESESSION.md (1816B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_COOKIESESSION 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_COOKIE (3) 9 - CURLOPT_COOKIEFILE (3) 10 - CURLOPT_COOKIEJAR (3) 11 Protocol: 12 - HTTP 13 Added-in: 7.9.7 14 --- 15 16 # NAME 17 18 CURLOPT_COOKIESESSION - start a new cookie session 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIESESSION, long init); 26 ~~~ 27 28 # DESCRIPTION 29 30 Pass a long set to 1 to mark this as a new cookie "session". It forces libcurl 31 to ignore all cookies it is about to load that are "session cookies" from the 32 previous session. By default, libcurl always loads all cookies, independent if 33 they are session cookies or not. Session cookies are cookies without expiry 34 date and they are meant to be alive and existing for this "session" only. 35 36 A "session" is usually defined in browser land for as long as you have your 37 browser up, more or less. libcurl needs the application to use this option to 38 tell it when a new session starts, otherwise it assumes everything is still in 39 the same session. 40 41 # DEFAULT 42 43 0 44 45 # %PROTOCOLS% 46 47 # EXAMPLE 48 49 ~~~c 50 int main(void) 51 { 52 CURL *curl = curl_easy_init(); 53 if(curl) { 54 CURLcode res; 55 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); 56 57 /* new "session", do not load session cookies */ 58 curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1L); 59 60 /* get the (non session) cookies from this file */ 61 curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/tmp/cookies.txt"); 62 63 res = curl_easy_perform(curl); 64 65 curl_easy_cleanup(curl); 66 } 67 } 68 ~~~ 69 70 # %AVAILABILITY% 71 72 # RETURN VALUE 73 74 curl_easy_setopt(3) returns a CURLcode indicating success or error. 75 76 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 77 libcurl-errors(3).