C ++ builder TIdHttp cannot obtain cookie, buildertidhttp
Use the TIdHttp component of c ++ builder to Get a page of the ASP. Net MVC server, obtain the Cookie information in the page, and Post the modification to the server.
After local debugging, you can obtain the Cookie. If you deploy it on the server, you cannot obtain the Cookie. You can use FireBug in FireFox to open the webpage and view the Cookie information. Then, you can use Wireshark to view the Get data, the Cookie has the HttpOnly attribute, and CookieManager of TIdHttp cannot obtain it. Search for the Cookie information found in m_IdHttp-> Response-> RawHeaders. Then, extract the Cookie and set the Cookie information in CustomHeaders of Requst.
The related code is as follows:
1 // obtain Cookie2 AnsiString cookies = m_IdHttp-> Response-> RawHeaders-> Values ["Set-Cookie"]; 3 // set Cookie4 m_IdHttp-> Request-> CustomHeaders-> AddValue ("Cookie", cookies );