1CURLOPT_COOKIEFILE(3)      curl_easy_setopt options      CURLOPT_COOKIEFILE(3)
2
3
4

NAME

6       CURLOPT_COOKIEFILE - file name to read cookies from
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIEFILE, char *filename);
12

DESCRIPTION

14       Pass  a  pointer  to  a  null-terminated string as parameter. It should
15       point to the file name of your file holding cookie data  to  read.  The
16       cookie  data  can  be  in either the old Netscape / Mozilla cookie data
17       format or just regular HTTP headers  (Set-Cookie  style)  dumped  to  a
18       file.
19
20       It  also enables the cookie engine, making libcurl parse and send cook‐
21       ies on subsequent requests with this handle.
22
23       Given an empty or non-existing file or by passing the empty string ("")
24       to  this  option,  you can enable the cookie engine without reading any
25       initial cookies. If you tell libcurl the file name is "-" (just a  sin‐
26       gle minus sign), libcurl will instead read from stdin.
27
28       This  option only reads cookies. To make libcurl write cookies to file,
29       see CURLOPT_COOKIEJAR(3).
30
31       If you use the Set-Cookie file format and do not specify a domain  then
32       the  cookie  is  not sent since the domain will never match. To address
33       this, set a domain in Set-Cookie line (doing that will include  sub-do‐
34       mains) or preferably: use the Netscape format.
35
36       If you use this option multiple times, you just add more files to read.
37       Subsequent files will add more cookies.
38
39       The application does not have to keep the string around  after  setting
40       this option.
41
42       Setting  this option to NULL will (since 7.77.0) explicitly disable the
43       cookie engine and clear the list of files to read cookies from.
44

DEFAULT

46       NULL
47

PROTOCOLS

49       HTTP
50

EXAMPLE

52       CURL *curl = curl_easy_init();
53       if(curl) {
54         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
55
56         /* get cookies from an existing file */
57         curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/tmp/cookies.txt");
58
59         ret = curl_easy_perform(curl);
60
61         curl_easy_cleanup(curl);
62       }
63
65       The cookie file format and general cookie  concepts  in  curl  are  de‐
66       scribed   in   the  HTTP-COOKIES.md  file,  also  hosted  online  here:
67       https://curl.se/docs/http-cookies.html
68

AVAILABILITY

70       As long as HTTP is supported
71

RETURN VALUE

73       Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
74

SEE ALSO

76       CURLOPT_COOKIE(3), CURLOPT_COOKIEJAR(3),
77
78
79
80libcurl 7.85.0                   May 17, 2022            CURLOPT_COOKIEFILE(3)
Impressum