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 zero 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       Exercise  caution  if  you are using this option and multiple transfers
33       may occur.  If you use the Set-Cookie format and don't specify a domain
34       then  the  cookie is sent for any domain (even after redirects are fol‐
35       lowed) and cannot be modified by a server-set cookie. If a server  sets
36       a  cookie  of the same name then both will be sent on a future transfer
37       to that server, likely not what you intended.  To address these  issues
38       set a domain in Set-Cookie (doing that will include sub-domains) or use
39       the Netscape format.
40
41       If you use this option multiple times, you just add more files to read.
42       Subsequent files will add more cookies.
43
44       The  application  does not have to keep the string around after setting
45       this option.
46

DEFAULT

48       NULL
49

PROTOCOLS

51       HTTP
52

EXAMPLE

54       CURL *curl = curl_easy_init();
55       if(curl) {
56         curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/foo.bin");
57
58         /* get cookies from an existing file */
59         curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/tmp/cookies.txt");
60
61         ret = curl_easy_perform(curl);
62
63         curl_easy_cleanup(curl);
64       }
65

AVAILABILITY

67       As long as HTTP is supported
68

RETURN VALUE

70       Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
71

SEE ALSO

73       CURLOPT_COOKIE(3), CURLOPT_COOKIEJAR(3),
74
75
76
77libcurl 7.61.1                  March 13, 2018           CURLOPT_COOKIEFILE(3)
Impressum