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.
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();
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With