cURL / Mailing Lists / curl-library / Single Mail


c++: cookies not working in libcurl

From: Shaaa <>
Date: Sat, 21 Aug 2010 11:12:04 +0100

Hi Guys

I am trying to get cookies for libcurl working in my C++ app. I have messed
around with the code for 2 days to no avail and am hoping someone can point
out the problem.
I can retrieve the page but it tells me I must be logged in to access the
content. I tried to access the content with wget --load-cookies (using the
same cookie) and it worked.
Any suggestions/pointers would be much appreciated. Code below:

string url = ""
/ Now set up all of the curl options
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_HEADER, 1);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writer);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "cookie.txt");
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "cookie.txt");

// Attempt to retrieve the remote page
result = curl_easy_perform(curl);

// Always cleanup

// Did we succeed?
if (result == CURLE_OK)

List admin:
Received on 2010-08-21