Answer the question
In order to leave comments, you need to log in
How to resend cookies correctly?
Hello!
Unable to save cookies and reuse in another request, minimal example:
There is one button in the widget, on which the print_inf() function is called
File widget.h
void print_inf() {
CURL *curl;
struct curl_slist *cookies;
CURL *curl;
CURLcode res;
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
curl_easy_setopt(curl, CURLOPT_COOKIELIST, &cookies);
res = curl_easy_perform(curl);
if(res != CURLE_OK) {
qDebug() << "bad connect\n";
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
}
else {
res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
struct curl_slist *nd;
nd = cookies;
qDebug() << "parse cookies";
while(nd)
{
const auto &p = nd->data;
qDebug() << p;
const auto &next = nd->next;
nd = next;
}
}
curl_easy_cleanup(curl);
}
curl_global_cleanup();
}
if(isset($_COOKIE["nameCookie"],$_COOKIE["nameCookie2"])) echo 'yes' else 'no';
Array\n(\n [Host] => 192.168.0.55\n [User-Agent] => Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)\n [Accept] => */*\n [test] => 500\n [test2] => 700\n [Content-Length] => 25\n [Content-Type] => application/x-www-form-urlencoded\n)
192.168.0.55 FALSE / FALSE 1539293470 nameCookie 100
192.168.0.55 FALSE / FALSE 1539293470 nameCookie2 100
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question