cURL / Mailing Lists / curl-library / Single Mail

curl-library

Libcurl - reading cookies offline

From: east2006 east2006 <east2006_at_gmail.com>
Date: Thu, 28 Apr 2011 23:13:11 +0300

Hi.

I'm trying to read my stored cookies offline, but gets nothing.

What am I doing wrong (I have cookie lines in the stored file)?

static void getCookieFromCURL(CURL *curl)

{

CURLcode res;

struct curl_slist *cookies;

struct curl_slist *nc;
int i;

    string cookieFile = "d:/tmp/cookies.txt";

    curl_easy_setopt(curl, CURLOPT_COOKIEFILE, cookieFile);
res = curl_easy_perform(curl);

curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookieFile);

res = curl_easy_perform(curl);

res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
if (res != CURLE_OK) {
    Logger::writeToLog("Curl curl_easy_getinfo failed");
}
nc = cookies, i = 1;
while (nc) {
    Logger::writeToLog("Cookie: "+String(i)+" "+String(nc->data));
    nc = nc->next;
    i++;
}
curl_easy_cleanup(curl);
curl_slist_free_all(cookies);

}

Thanks

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-04-28