5

I'm upgrading an application from QtWebKit to QtWebEngine. The application relied on that WebKit didn't keep cookies after closing the app but WebEngine seems to keep them by default.

I'm not familiar with Qt at all. I've been browsing the documentation but I can't seem to find the right API calls to delete them. The application just has a simple QWebEngineView for the front end.

1
  • Using Qt 5.6 (windows) if that matters.
    – toster-cx
    Jan 10, 2016 at 13:19

2 Answers 2

12

In case when there is no need to change PersistentCookiesPolicy, but you only need to clean Cookies, then you may use method deleteAllCookies() of the class QWebEngineCookieStore.

So you can do something like this:

webEngineView->page()->profile()->cookieStore()->deleteAllCookies();
8

There is QWebEngineProfile class that you may use.

void QWebEngineProfile::setPersistentCookiesPolicy(QWebEngineProfile::PersistentCookiesPolicy newPersistentCookiesPolicy)

Sets the policy for persistent cookies to newPersistentCookiesPolicy.

So you can do something like this:

webEngineView->page()->profile()->setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies);
1
  • It's the default setting in Qt6
    – iMath
    Mar 5 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.