Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to make a custom cookie jar?

How to make a custom cookie jar?

Scheduled Pinned Locked Moved General and Desktop
9 Posts 2 Posters 2.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nicky j
    wrote on 23 Feb 2014, 00:06 last edited by
    #1

    Hello there,

    I have been working on my web browser, and I am wondering how I could make a cookie jar. I am not sure how I would go about this. Any suggestions?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JKSH
      Moderators
      wrote on 7 Mar 2014, 23:06 last edited by
      #2

      This example subclasses QNetworkCookieJar: http://qt-project.org/doc/qt-5/qtwebkitexamples-webkitwidgets-browser-example.html

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nicky j
        wrote on 8 Mar 2014, 21:06 last edited by
        #3

        that exactly what Im looking for, thanks!

        1 Reply Last reply
        0
        • N Offline
          N Offline
          nicky j
          wrote on 8 Mar 2014, 21:14 last edited by
          #4

          If I use QNetworkCookieJar, will I have to tell my webView to check if there is a cookie from the site its loading already in my cookie jar? If so how do I do this? Thanks!

          1 Reply Last reply
          0
          • J Offline
            J Offline
            JKSH
            Moderators
            wrote on 9 Mar 2014, 00:07 last edited by
            #5

            I don't know, sorry; I've never done something like this before.

            I imagine that the example shows you how to make QWebView interact with the custom cookie jar.

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            0
            • N Offline
              N Offline
              nicky j
              wrote on 9 Mar 2014, 00:52 last edited by
              #6

              Ok so I have subclassed QNetworkCookieJar and made my custom cookie jar called NBcookieJar. I would like to be able to use NBcookieJar as an argument for one of my classes. I have several classes: mainView, browseTab, and NBcookieJar. mainView creates an instance of browseTab which contains a QWebView. I would like to also create an instance of NBcookieJar in mainView and use that instance as a parameter when creating the browseTab.

              I tried to do this but I got this error:
              error: missing default argument on parameter 'jar'

              I realize that I have not provided a default argument, but I have no idea what kind of argument I am supposed to provide.

              here is my code:
              browseTab.h:
              @
              public:
              explicit browseTab(QWidget *parent = 0, QString url = "www.google.com", NBcookieJar jar);
              @

              browseTab.cpp:
              @browseTab::browseTab(QWidget *parent, QString url, NBcookieJar jar) :
              QWidget(parent),@

              What is the default argument I should give for NBcookieJar jar?

              Thanks!

              1 Reply Last reply
              0
              • J Offline
                J Offline
                JKSH
                Moderators
                wrote on 9 Mar 2014, 01:22 last edited by
                #7

                Why do you pass your cookie jar by-value? You will end up with multiple copies of the cookie jar. When a cookie arrives, it will be stored in one jar, and the other copies won't get the cookie.

                You should pass pointers or references to the cookie jar instead.

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                0
                • N Offline
                  N Offline
                  nicky j
                  wrote on 9 Mar 2014, 01:34 last edited by
                  #8

                  Yep just figured it out, changed the argument to a pointer. I declared the instance of NBcookieJar in mainView, then passed that to the argument. That way all the cookies are being stored in the instance in mainView and are accessible to all the browseTab's that are open. Works great! but now I need to figure out how to save the cookies to disk and manage them (I believe QNetworkCookieJar just saves them in memory until the application closes). Any ideas?

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    JKSH
                    Moderators
                    wrote on 9 Mar 2014, 01:46 last edited by
                    #9

                    It's in the example

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved