Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Access the qml webview cookies from c++
Forum Updated to NodeBB v4.3 + New Features

Access the qml webview cookies from c++

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 2 Posters 2.8k Views 2 Watching
  • 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.
  • K Offline
    K Offline
    Krasi
    wrote on last edited by
    #1

    Hi

    I am using the simple webview qml and now I need to find a way to access the cookies as these will be needed to make api calls to a web portal.

    I want to use webview as I want to use this app on android(webengine doesn't support android) as well as desktop.

    Here is the code.
    https://github.com/vipconsult/portalChat

    you can git clone and build it.

    the first tab is where I will login and the second tab is where I will make the api calls but need to use the cookies for the authentication to the api.

    appreciate any suggestions.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @Krasi

      Access the qml webview cookies from c++

      I doubt that it is possible because there is no public C++ API for it.
      May be you can try accessing it in QML using runJavaScript as per this and then some how forward the result to C++ ?

      157

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Krasi
        wrote on last edited by
        #3

        yes that might be a some weird solution.

        Do you know where the webview stores the cookies and if it is some standard format so I can maybe read and parse the file directly

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @Krasi On Linux desktop systems WebView uses chrome. So the default location on it will be .local/share/ApplicationName/QtWebEngine/Default/Cookies in user's home directory.
          Also it wont be a flat file but a SQLite database.

          157

          1 Reply Last reply
          0
          • K Offline
            K Offline
            Krasi
            wrote on last edited by
            #5

            Thanks , I did some strace and figured the file location, but I don't think there is any uniform way to access the file regarding on which platform it is . I guess android and ios might not even use sqlite.

            p3c0P 1 Reply Last reply
            0
            • K Krasi

              Thanks , I did some strace and figured the file location, but I don't think there is any uniform way to access the file regarding on which platform it is . I guess android and ios might not even use sqlite.

              p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              @Krasi said in Access the qml webview cookies from c++:

              but I don't think there is any uniform way to access the file regarding on which platform it is...

              According to me the best way if it is possible is to go through the JS method I described in first post.

              I guess android and ios might not even use sqlite.

              Atleast android does. The database is stored in the data folder of each application's sandboxed environment.

              157

              1 Reply Last reply
              0
              • K Offline
                K Offline
                Krasi
                wrote on last edited by
                #7

                Yes the JS method works fine. Thanks a lot for the suggestion.

                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