| 1 |
.\" ************************************************************************** |
| 2 |
.\" * _ _ ____ _ |
| 3 |
.\" * Project ___| | | | _ \| | |
| 4 |
.\" * / __| | | | |_) | | |
| 5 |
.\" * | (__| |_| | _ <| |___ |
| 6 |
.\" * \___|\___/|_| \_\_____| |
| 7 |
.\" * |
| 8 |
.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <[email protected]>, et al. |
| 9 |
.\" * |
| 10 |
.\" * This software is licensed as described in the file COPYING, which |
| 11 |
.\" * you should have received as part of this distribution. The terms |
| 12 |
.\" * are also available at https://curl.haxx.se/docs/copyright.html. |
| 13 |
.\" * |
| 14 |
.\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell |
| 15 |
.\" * copies of the Software, and permit persons to whom the Software is |
| 16 |
.\" * furnished to do so, under the terms of the COPYING file. |
| 17 |
.\" * |
| 18 |
.\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 19 |
.\" * KIND, either express or implied. |
| 20 |
.\" * |
| 21 |
.\" ************************************************************************** |
| 22 |
.\" |
| 23 |
.TH CURLOPT_COOKIE 3 "17 Jun 2014" "libcurl 7.37.0" "curl_easy_setopt options" |
| 24 |
.SH NAME |
| 25 |
CURLOPT_COOKIE \- set contents of HTTP Cookie header |
| 26 |
.SH SYNOPSIS |
| 27 |
#include <curl/curl.h> |
| 28 |
|
| 29 |
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIE, char *cookie); |
| 30 |
.SH DESCRIPTION |
| 31 |
Pass a pointer to a zero terminated string as parameter. It will be used to |
| 32 |
set a cookie in the HTTP request. The format of the string should be |
| 33 |
NAME=CONTENTS, where NAME is the cookie name and CONTENTS is what the cookie |
| 34 |
should contain. |
| 35 |
|
| 36 |
If you need to set multiple cookies, set them all using a single option |
| 37 |
concatenated like this: "name1=content1; name2=content2;" etc. |
| 38 |
|
| 39 |
This option sets the cookie header explicitly in the outgoing request(s). If |
| 40 |
multiple requests are done due to authentication, followed redirections or |
| 41 |
similar, they will all get this cookie passed on. |
| 42 |
|
| 43 |
The cookies set by this option are separate from the internal cookie storage |
| 44 |
held by the cookie engine and will not be modified by it. If you enable the |
| 45 |
cookie engine and either you've imported a cookie of the same name (e.g. 'foo') |
| 46 |
or the server has set one, it will have no effect on the cookies you set here. |
| 47 |
A request to the server will send both the 'foo' held by the cookie engine and |
| 48 |
the 'foo' held by this option. To set a cookie that is instead held by the |
| 49 |
cookie engine and can be modified by the server use |
| 50 |
\fICURLOPT_COOKIELIST(3)\fP. |
| 51 |
|
| 52 |
Using this option multiple times will only make the latest string override the |
| 53 |
previous ones. |
| 54 |
|
| 55 |
This option will not enable the cookie engine. Use \fICURLOPT_COOKIEFILE(3)\fP |
| 56 |
or \fICURLOPT_COOKIEJAR(3)\fP to enable parsing and sending cookies |
| 57 |
automatically. |
| 58 |
|
| 59 |
The application does not have to keep the string around after setting this |
| 60 |
option. |
| 61 |
.SH DEFAULT |
| 62 |
NULL, no cookies |
| 63 |
.SH PROTOCOLS |
| 64 |
HTTP |
| 65 |
.SH EXAMPLE |
| 66 |
.nf |
| 67 |
CURL *curl = curl_easy_init(); |
| 68 |
if(curl) { |
| 69 |
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com"); |
| 70 |
|
| 71 |
curl_easy_setopt(curl, CURLOPT_COOKIE, "tool=curl; fun=yes;"); |
| 72 |
|
| 73 |
curl_easy_perform(curl); |
| 74 |
} |
| 75 |
.fi |
| 76 |
.SH AVAILABILITY |
| 77 |
If HTTP is enabled |
| 78 |
.SH RETURN VALUE |
| 79 |
Returns CURLE_OK if HTTP is enabled, CURLE_UNKNOWN_OPTION if not, or |
| 80 |
CURLE_OUT_OF_MEMORY if there was insufficient heap space. |
| 81 |
.SH "SEE ALSO" |
| 82 |
.BR CURLOPT_COOKIEFILE "(3), " CURLOPT_COOKIEJAR "(3), " CURLOPT_COOKIELIST "(3), " |
| 83 |
.BR CURLOPT_HTTPHEADER "(3), " |