Results 1 to 6 of 6

Thread: How to enable cookie in QWebView

  1. #1
    Join Date
    May 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to enable cookie in QWebView

    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,

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to enable cookie in QWebView

    As far as I remember You have to set a cookie jar for the view (or for the QNetworkAccessManager that runs it).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to enable cookie in QWebView

    Quote Originally Posted by wysota View Post
    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to enable cookie in QWebView

    Quote Originally Posted by KoalaSydney View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jun 2009
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to enable cookie in QWebView

    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.

  6. #6
    Join Date
    Jul 2013
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to enable cookie in QWebView

    Quote Originally Posted by vides2012 View Post
    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.

Similar Threads

  1. Problem With QWebView
    By ivi2501 in forum Qt Programming
    Replies: 8
    Last Post: 2nd August 2009, 19:37
  2. Problems of embedded QWebView in QGraphicsView
    By naruto_9w in forum Qt Programming
    Replies: 2
    Last Post: 20th February 2009, 15:22
  3. QWebView transparent problem
    By embedyy in forum Qt Programming
    Replies: 4
    Last Post: 16th January 2009, 06:20
  4. QWebView - retrieving information?
    By lamera in forum Qt Programming
    Replies: 1
    Last Post: 25th September 2008, 17:53
  5. printing QWebView before showing in Dialog
    By Grisu in forum Qt Programming
    Replies: 1
    Last Post: 17th July 2008, 12:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.