Question

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.

Was it helpful?

Solution

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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top