1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.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)
11Protocol:
12  - HTTP
13Added-in: 7.9.7
14---
15
16# NAME
17
18CURLOPT_COOKIESESSION - start a new cookie session
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIESESSION, long init);
26~~~
27
28# DESCRIPTION
29
30Pass a long set to 1 to mark this as a new cookie "session". It forces libcurl
31to ignore all cookies it is about to load that are "session cookies" from the
32previous session. By default, libcurl always loads all cookies, independent if
33they are session cookies or not. Session cookies are cookies without expiry
34date and they are meant to be alive and existing for this "session" only.
35
36A "session" is usually defined in browser land for as long as you have your
37browser up, more or less. libcurl needs the application to use this option to
38tell it when a new session starts, otherwise it assumes everything is still in
39the same session.
40
41# DEFAULT
42
430
44
45# %PROTOCOLS%
46
47# EXAMPLE
48
49~~~c
50int 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
74Returns CURLE_OK
75