C++ Libcurl-cookie身份验证
我想避免在使用带有Libcurl的cookies时使用文件系统……这可能吗?似乎文档和示例都需要使用从文件中写入和读取cookies…也许我错了 到目前为止,我正在做这样的事情:C++ Libcurl-cookie身份验证,c++,libcurl,C++,Libcurl,我想避免在使用带有Libcurl的cookies时使用文件系统……这可能吗?似乎文档和示例都需要使用从文件中写入和读取cookies…也许我错了 到目前为止,我正在做这样的事情: curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_POST, 1); curl_easy_setopt(curl, C
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postfield);
curl_easy_setopt(curl, CURL_HTTPAUTH, CURLAUTH_BASIC);
curl_easy_setopt(curl, CURLOPT_USERPWD, userpass);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writer);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
//writes the cookie to file sent from server
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, COOKIE_FILENAME);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
不使用文件系统也可以打印和编辑cookie
我自己也用过这个例子来做整个修改饼干的事情
也很有用,示例中没有:
curl_easy_setopt(curl, CURLOPT_COOKIE, "name=xxx; name2=xxx;");
更新了我原来的帖子。您提供的两个示例都在代码本身中创建cookie…我想保存从服务器发回的cookie(但不保存在文件中)。