|
NAMECURLOPT_COOKIELIST - add to or manipulate cookies held in memory SYNOPSIS#include <curl/curl.h> CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIELIST, DESCRIPTIONPass a char pointer to a cookie string. Such a cookie can be either a single line in Netscape / Mozilla format or just regular HTTP-style header (Set-Cookie:) format. This option also enables the cookie engine. This adds that single cookie to the internal cookie store. We strongly advice against loading cookies from an HTTP header file, as that is an inferior data exchange format. Exercise caution if you are using this option and multiple transfers may occur. If you use the Set-Cookie format and the string does not specify a domain, then the cookie is sent for any domain (even after redirects are followed) and cannot be modified by a server-set cookie. If a server sets a cookie of the same name (or maybe you have imported one) then both are sent on future transfers to that server, likely not what you intended. To address these issues set a domain in Set-Cookie (doing that includes subdomains) or much better: use the Netscape file format. Additionally, there are commands available that perform actions if you pass in these exact strings: DEFAULTNULL PROTOCOLSThis functionality affects http only EXAMPLE/* an inline import of a cookie in Netscape format. */
#define SEP "\t" /* Tab separates the fields */
int main(void)
{
Cookie file formatThe cookie file format and general cookie concepts in curl are described online here: https://curl.se/docs/http-cookies.html HISTORYALL was added in 7.14.1 SESS was added in 7.15.4 FLUSH was added in 7.17.1 RELOAD was added in 7.39.0 AVAILABILITYAdded in curl 7.14.1 RETURN VALUEcurl_easy_setopt(3) returns a CURLcode indicating success or error. CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3). SEE ALSOCURLINFO_COOKIELIST(3), CURLOPT_COOKIE(3), CURLOPT_COOKIEFILE(3), CURLOPT_COOKIEJAR(3)
|