cURL / Mailing Lists / curl-users / Single Mail

curl-users

getting cookies to work with libcurl c++

From: Shaaa <shaolinfinest_at_gmail.com>
Date: Tue, 17 Aug 2010 21:40:26 +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 with my code:

string url = "http://mysite.com/get=1"
/ 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
curl_easy_cleanup(curl);

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

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-08-17