我在site中使用libcurl进行身份验证。我用许多功能制作它,例如:
char *CheckLoginPass(char *login, char *pass)
{
//use curl_easy_setopt for check login/pass
return stdout;
}
char *AuthOnSite() //make auth on site
{
//use curl_easy_setopt for auth by login/pass
return htmlpage;
}
char *TestMyAuth()
{
//use curl_easy_setopt for test auth
return htmlpage;
}
void Test()
{
char *stdout = CheckLoginPass("login", "pass"); // is good
char *htmlpage = AuthOnSite(); // is good
htmlpage = TestMyAuth(); // session is lose and I am not logined on site
}
我怎么做才能避免掉线?
您需要
为 libcurl 配置一个"cookie jar"来存储其会话 cookie,请参阅:https://curl.haxx.se/libcurl/c/CURLOPT_COOKIEJAR.html 并在进行 TestMyAuth 调用时参考该内容,请参阅:https://curl.haxx.se/libcurl/c/CURLOPT_COOKIEFILE.html