Home > Software engineering >  W3Client class how to use cookies
W3Client class how to use cookies

Time:09-22

https://www.codeproject.com/Articles/6939/WWW-HTTP-HTTPS-FTP-Client-using-WININET
 
Char RetBuf [1024]="\ 0";
W3Client client;
Client. The Connect (" https://api.xxxxxxx.com ");
Client. AddPostArgument (" user ", "admin");
Client. AddPostArgument (" pw ", "123456");

If (client Request ("/login HTML ", W3Client: : reqPost))
{
While (client. The Response (reinterpret_cast & lt; Unsigned char * & gt; (RetBuf), 1024) & gt; 0)
{
OutputDebugString (RetBuf);
}
}

HTTPS post call is normal, but again after a successful login Internet call requires first login cookie, because the case didn't have access to setting cookies, so can only guess

 
Char RetCookieBuf [1024]="\ 0";
Client. QueryCookie (RetCookieBuf (BYTE *), 1024, 0).

This should be obtained for the first time login cookie, RetCookieBuf======JSESSIONID=184934 bfe67c88d808f9f4c54b7f236e; Path=/; HttpOnly
The question now is when connected to the second time how to set up in this cookie??
 
Char RetBuf [1024]="\ 0";
W3Client client;
Client. The Connect (" https://api.xxxxxxx.com ");
Client. AddPostArgument (" API ", "Fun1");
Client. AddPostArgument (" data ", "123456");

If (client Request ("/API. HTML ", W3Client: : reqPost))
{
While (client. The Response (reinterpret_cast & lt; Unsigned char * & gt; (RetBuf), 1024) & gt; 0)
{
OutputDebugString (RetBuf);
}
}


Try to use the==client. AddCookie (RetCookieBuf, 0). Don't know what parameters should be fill in value? From where? The old driver to lead the way, please
  • Related