QNetworkAccesManager can't get to another page after NetworkRequest post



  • After I succsesfully send post request and login to page I can't get to another page during same session. for example

    I login to www.example.com/login.php and then webpage redirects me to index.php and from index page I want to go to www.example.com/data.php.

    But reply returns me only login.php page.

    Here is my code

    @QNetworkAccessManager *manager;
    manager = new QNetworkAccessManager ();
    QNetworkRequest req;

    address =("www.example/index.php");

        manager->setCookieJar(new QNetworkCookieJar);
    
        req.setHeader(req.UserAgentHeader,"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2");
        req.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
        req.setUrl(QUrl("www.example.com/login"));
    
            QByteArray postData;
    
            postData.append("login_user=user&");
            postData.append("login_passwd=Pass");
    
    connect (manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(writeToTxt(QNetworkReply  *))); 
    
    manager->post(req, postData);
    manager->get(QNetworkRequest(address));
    manager->get(QNetworkRequest(QUrl("www.example.com/example.html")));@
    

    I just have no idea where to start searching for problem. Post any ideas i will really appreciate them.

    And sorry English is not my native language.



  • you should get session ID from webpage and keep that to GET or POST .


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.