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 *file‐
12       name);
13

DESCRIPTION

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

DEFAULT

47       NULL
48

PROTOCOLS

50       HTTP
51

EXAMPLE

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

AVAILABILITY

71       As long as HTTP is supported
72

RETURN VALUE

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

SEE ALSO

77       CURLOPT_COOKIE(3), CURLOPT_COOKIEJAR(3),
78
79
80
81libcurl 7.79.1                   May 16, 2021            CURLOPT_COOKIEFILE(3)
Impressum