How to save the http session in qt application

怎甘沉沦 提交于 2019-12-11 03:39:01

问题


Now I have a web server written with php. And there some php script files for database accessing. I'm writing a Qt app to send get/post request to the remote php scripts. However, it's not convenient to verify user identity for each request. So, I want to use session control on the web server. But I don't know how to do in Qt application.


回答1:


As Orangepill and PLB said, the solution is Passing cookies to the request url, you may refer to QNetworkAccessManager::setCookieJar.

Steps

  1. Instantiate the QNetworkAccessManager object and call setCookieJar for it.
  2. Send POST request to the authenticate page which activates a session. Then you will have cookies got from the page in the cookieJar.
  3. Send requests to the pages under the domain will with the session alive.


来源:https://stackoverflow.com/questions/17669978/how-to-save-the-http-session-in-qt-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!