Handling Cookies and redirects. the right way!?
-
Basically, I want to automate a task of logging in (by doing POST) to a website & doing another POST.
Doing the 2nd POST requires cookies which were sent to me when I did login to the site.
After doing login to the site, I am also get redirected to pages, so I want to handle that too.
THe time I make the second POST to the server, I want to send the cookies which were sent to me earlier while logging in.
I have tried doing this but was unsuccessful. Here is "my post regarding that effort":http://stackoverflow.com/questions/4509441/qt-http-post-issue-when-server-requires-cookies.
I posted in other places too but could get a reply of which I could get real benefit. So, I decided for fresh start..
Please spend a moment to see how I accomplished this "task very easily in python":http://linux-junky.blogspot.com/2010/03/python-script-for-sending-free-sms-in.html
Guide me on how do I accomplish this task.. I have a hobby app on hold due to this. I really want to know how do I do that in C++ Qt. -
The similar code example is given here :"how to handle an HTTP redirect with QNetworkAccessManager.":http://wiki.forum.nokia.com/index.php/CS001432_-_Handling_an_HTTP_redirect_with_QNetworkAccessManager
Which may be help you.
Generally, Login page requires the servers confirmation regarding automatic login.
Best regards,
-
Thanks for your input. But, if you would checked all details of post, I have already tried that. See stackoverflow link.. I am having issue on how to handle cookies..
Does making another call through QNetworkAccountManager wipes out the content of cookiejar which existed earlier?
[quote author="qtrahul" date="1293090661"]The similar code example is given here :"how to handle an HTTP redirect with QNetworkAccessManager.":http://wiki.forum.nokia.com/index.php/CS001432_-_Handling_an_HTTP_redirect_with_QNetworkAccessManagerWhich may be help you.
Generally, Login page requires the servers confirmation regarding automatic login.
Best regards,[/quote]
-
cookieJar() and setCookieJar() from "QNetworkAccessManager": http://doc.qt.nokia.com/stable/qnetworkaccessmanager.html together with cookiesForUrl() and setCookiesFromUrl() from "QNetworkCookieJar":http://doc.qt.nokia.com/stable/qnetworkcookiejar.html
The rest depends on what you actually want to do, which you did not describe here. Code on stackoverflow that isn't working does not count....