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

NAME

6       CURLOPT_COOKIE - set contents of HTTP Cookie header
7

SYNOPSIS

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

DESCRIPTION

14       Pass  a  pointer  to  a zero terminated string as parameter. It will be
15       used to set a cookie in the HTTP request.  The  format  of  the  string
16       should  be NAME=CONTENTS, where NAME is the cookie name and CONTENTS is
17       what the cookie should contain.
18
19       If you need to set multiple cookies, set them all using a single option
20       concatenated like this: "name1=content1; name2=content2;" etc.
21
22       This   option  sets  the  cookie  header  explicitly  in  the  outgoing
23       request(s). If multiple requests are done due to  authentication,  fol‐
24       lowed redirections or similar, they will all get this cookie passed on.
25
26       The  cookies  set  by this option are separate from the internal cookie
27       storage held by the cookie engine and will not be modified  by  it.  If
28       you enable the cookie engine and either you've imported a cookie of the
29       same name (e.g. 'foo') or the server has  set  one,  it  will  have  no
30       effect  on the cookies you set here.  A request to the server will send
31       both the 'foo' held by the cookie engine and the  'foo'  held  by  this
32       option.  To  set a cookie that is instead held by the cookie engine and
33       can be modified by the server use CURLOPT_COOKIELIST(3).
34
35       Using this option multiple times will only make the latest string over‐
36       ride the previous ones.
37
38       This  option  will  not  enable  the  cookie  engine. Use CURLOPT_COOK‐
39       IEFILE(3) or CURLOPT_COOKIEJAR(3) to enable parsing and sending cookies
40       automatically.
41
42       The  application  does not have to keep the string around after setting
43       this option.
44

DEFAULT

46       NULL, no cookies
47

PROTOCOLS

49       HTTP
50

EXAMPLE

52       CURL *curl = curl_easy_init();
53       if(curl) {
54         curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
55
56         curl_easy_setopt(curl, CURLOPT_COOKIE, "tool=curl; fun=yes;");
57
58         curl_easy_perform(curl);
59       }
60

AVAILABILITY

62       If HTTP is enabled
63

RETURN VALUE

65       Returns CURLE_OK if HTTP is enabled, CURLE_UNKNOWN_OPTION  if  not,  or
66       CURLE_OUT_OF_MEMORY if there was insufficient heap space.
67

SEE ALSO

69       CURLOPT_COOKIEFILE(3),   CURLOPT_COOKIEJAR(3),   CURLOPT_COOKIELIST(3),
70       CURLOPT_HTTPHEADER(3),
71
72
73
74libcurl 7.66.0                 December 21, 2016             CURLOPT_COOKIE(3)
Impressum