//COOKIELIST
static string cookieStr = "";
if(cookieStr.length()>0)
{
curl_easy_setopt(conn, CURLOPT_COOKIELIST, cookieStr.data());
}
code = curl_easy_setopt(conn, CURLOPT_COOKIEFILE, "");//启动cookie引擎
//code= curl_easy_setopt(conn, CURLOPT_COOKIEFILE, "cookies.txt");
//code = curl_easy_setopt(conn, CURLOPT_COOKIEJAR, "cookies.txt");
......
......
......
struct curl_slist * cookies;
code=curl_easy_getinfo(conn, CURLINFO_COOKIELIST, &cookies);
cookieStr = "";
if(code== CURLE_OK)
{
struct curl_slist *each = cookies;
while (each)
{
if (cookieStr.length() > 0)
{
cookieStr = cookieStr + "\r\n";
}
//printf("cookie:%s\n", each->data);
cookieStr = cookieStr + each->data;//获取cookie
each = each->next;
}
}
curl_slist_free_all(cookies);
curl_easy_cleanup(conn);