5

I'am creating easy QT application named "webengine"

pWebView = new QWebEngineView(this);
pWebView->load(QUrl("http://technoz.ru"));
pWebView->show();
// On application close
delete pWebView;

The application creates a standard folder named "webengine" for storage and cookies. Domain sets a cookie for 24 hours. But after closing and opening the application again, the cookies lost. Сookies file created in the folder "webengine" - empty(I check it in sqlbrowser). But, if you hold on page 30 - 40 seconds, cookies are saved.

Why cookies are not saved immediately, and how to save them immediately?


During testing, it turned out that the QT(chromium) automatically stores the cookies through the browser in 30 seconds(constant) if the elapsed time is less, cookies are not saved. Is it possible to change this time? I tried to use the flag - --profiling-flush=5, but it does not help.

Given that the browser must preserve storage(cookies) when you close the browser, but it does not, whether it is a bug QT?


I can build QT from source, аnd find and change this setting in source, i think, but, perhaps this problem have other solution...


Thanks for all, found it bug: https://bugreports.qt.io/browse/QTBUG-52121

musicamante
  • 41,230
  • 6
  • 33
  • 58

1 Answers1

3

You have to edit the cookie storage policy of your QWebEngineProfile. If you are using the default profile, use:

QWebEngineProfile::defaultProfile()->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies)

Both session and persistent cookies are saved to and restored from disk. You can select the folder in which you will save the cookies and cache data:

QWebEngineProfile* defaultProfile = QWebEngineProfile::defaultProfile();
defaultProfile->setCachePath("your folder");
defaultProfile->setPersistentStoragePath("your folder"); 
mohabouje
  • 3,867
  • 2
  • 14
  • 28