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