Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/130.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Libcurl-cookie身份验证_C++_Libcurl - Fatal编程技术网

C++ Libcurl-cookie身份验证

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

我想避免在使用带有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, 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(但不保存在文件中)。