[SOLVED] Cookies are no longer persistent in Qt6 with QtWebEngineQuick
-
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.aspAs 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 ?
-
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"));
-
-