Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. [SOLVED] Cookies are no longer persistent in Qt6 with QtWebEngineQuick
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Cookies are no longer persistent in Qt6 with QtWebEngineQuick

Scheduled Pinned Locked Moved Solved QtWebEngine
2 Posts 1 Posters 685 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.
  • P Offline
    P Offline
    plaristote
    wrote on last edited by plaristote
    #1

    Hi ! I recently ported a Qt application to Qt6, and it seems cookies are no longer persisted when the application stops.

    I noticed the persistentCookiePolicy and offTheRecord properties on WebEngineView, but using it as following doesn't fix the issue:

    import QtQuick
    import QtWebEngine
    
    WebEngineView {
      profile.persistentCookiesPolicy: WebEngineProfile.ForcePersistentCookies
      profile.offTheRecord: false
    }
    

    I also tried setting those properties on the default QQuickWebEngineProfile, after initializing QtWebEngineQuick and before loading the QML engine:

    QQuickWebEngineProfile::defaultProfile()->setPersistentCookiesPolicy(QQuickWebEngineProfile::ForcePersistentCookies);
    QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(false);
    

    But that didn't work either. The profile is supposedly stored in ~./local/share/KDE/kfeedreader/QtWebEngine/UnknownProfile, and that folder does exist and contains some persisted data, but the cookies are either not stored, or not loaded after the application restarts.

    The state of cookie persistence can be checked using the following test page:
    https://www.whatarecookies.com/cookietest.asp

    As soon as an application restarts, all cookies are cleared. I do not believe this is the expected behavior. But maybe I'm still missing some settings ?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      plaristote
      wrote on last edited by
      #2

      I solved the issue. The cookie policy and offTheRecord properties are not enough.

      It is also mandatory to set a cachePath, and possibly a storageName, as following:

      QQuickWebEngineProfile* webEngineProfile = QQuickWebEngineProfile::defaultProfile();
      
      webEngineProfile->setPersistentCookiesPolicy(QQuickWebEngineProfile::ForcePersistentCookies);
      webEngineProfile->setOffTheRecord(false);
      webEngineProfile->setStorageName(QStringLiteral("Default"));
      webEngineProfile->setCachePath(webEngineProfile->persistentStoragePath() + QStringLiteral("/Cache"));
      
      1 Reply Last reply
      0
      • P plaristote has marked this topic as solved on
      • P plaristote has marked this topic as solved on

      • Login

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