PDA

View Full Version : How to enable cookie in QWebView



KoalaSydney
28th May 2009, 03:50
The main program is in C++ & Qt. The reporting system is in PHP web. I intend to access PHP web in my C++ GUI, by using QWebView as an internal browswer. Does anyone know how to enable the cookie in QWebView so that users can browse in the QWebView just as in normal browser?

Thanks,

wysota
28th May 2009, 09:16
As far as I remember You have to set a cookie jar for the view (or for the QNetworkAccessManager that runs it).

KoalaSydney
28th May 2009, 14:38
As far as I remember You have to set a cookie jar for the view (or for the QNetworkAccessManager that runs it).

Is it like this -
view->page->networkAccessManager()->setCookieJar( new QNetworkCookieJar() );

BTW, what is cookie jar? I have very little knowledge about qwebkit.

wysota
28th May 2009, 14:52
Is it like this -
view->page->networkAccessManager()->setCookieJar( new QNetworkCookieJar() );
Maybe. But I'm not sure - maybe you have to fill the jar yourself when the data arrives. You can take a look at arora (google for it) code or the Qt demo browser.


BTW, what is cookie jar? I have very little knowledge about qwebkit.

It's not about webkit. It's about web browsers at all. This is a place (usually a file or directory) where a browser keeps its cookies.

vides2012
21st June 2009, 16:37
Hi!

I would like to use QtWebkit to log in to a site, and then download some data.Unfortunately if I load the page with the webkit( QWebView::load()) I cant log in, and the site claims that I don't have cookies enabled, even though I have created a QNetworkCookieJar, and set it to the QNetworkAccessManager of the page.

I tried to manually copy the protocol, and save the cookies, using QHttp, and the headers, but apparently some javascript code generates an ID to be sent to the site when logging in.

Please help me log in(and stay logged in) either with using QtWebkit, or with simple QHttp classes.

Any reply would be appreciated.

dolevo
21st July 2014, 05:56
Hi!

I would like to use QtWebkit to log in to a site, and then download some data.Unfortunately if I load the page with the webkit( QWebView::load()) I cant log in, and the site claims that I don't have cookies enabled, even though I have created a QNetworkCookieJar, and set it to the QNetworkAccessManager of the page.

I tried to manually copy the protocol, and save the cookies, using QHttp, and the headers, but apparently some javascript code generates an ID to be sent to the site when logging in.

Please help me log in(and stay logged in) either with using QtWebkit, or with simple QHttp classes.

Any reply would be appreciated.


Hi,
Could you please tell me how you solved this issue? I am facing with a similar one and pretty annoying. Thanks.