Login in the site



  • Hellow, i want to login in the site and i do it right, and server get me QNetworkReply, how can i check if login right or not, url are always the same
    I login in the site with post request
    Advance many thanks for your help!



  • Which site are you talking about?



  • Hi Ruzik, you should write more details about the issue so others can help you better. Maybe a code snippet or something. Cheers!



  • @
    QString login = "login";
    siteUrl = "http://site.com/";
    QString pass = "password";
    QString postRequest = QString("login_pup=%1&passw;_pup=%2&do_auth=yes").arg(login,pass);
    QNetworkAccessManager pManager = new QNetworkAccessManager;
    connect(pManager, SIGNAL(finished(QNetworkReply
    )), this, SLOT(replyFinished(QNetworkReply*)));
    pManager->post(QNetworkRequest(QUrl(siteUrl)), postRequest.toUtf8());@
    //Slot replyFinished
    @void POST::replyFinished(QNetworkReply* reply)
    {
    QString answer = reply->readAll();
    if (answer.indexOf("Wrong password!")!=-1)
    {
    label->setText("Error");
    }
    else
    label->setText("OK");
    }@
    As you see i chek right of password by save http in QString and find text in it, how can i chek it without save in QString, because site can weigh quite a lot



  • Try look full raw request header from your browser when you do login, may be you are missing something.
    You can do it with Wireshark tool or with using specially plugins for your browser, for example, I (in simple cases) use firefox with HttpFox addon



  • As i understand, you dont understand me: I login in site right, it is work, bit when i want chek is it right login and password i must save all page of site, but it is weighs a lot how can i do it with, for example reply which returns the server



  • Ah... ok... It depends of site
    for example, some sites doing redirect after correct (or incorrect) login. You can check raw responses for both cases. Also almost always sites are setting any cookie flag (in response header) about user was logging. if it is correct things for your site, you can save only header bytes and check state with it.



  • if i right
    @qDebug() << reply->header(QNetworkRequest::CookieHeader);@
    in slot, i get
    QVariant(, ) , if password and login right or not, and url of site after right and not right login are same



  • There will not be a single solution that fits all website. You will have to do some investigation and see what happens in both cases (e.g. the site may be updated showing a wrong password banner you can check for, or as Vass said you might be redirected to a different website). We won't be able to help you with that (not unless you tell us what website we're talking about of course).



  • bq. the dite may be updated showing a wrong password banner you can check for

    I do it now, but it is very long

    This is example of site with which the program will work: http://gimn87.sarobraz.ru/, sorry but it is on the russian and there are no free registration and so i dont know whether this sense of


Log in to reply