How to clear all browser storage?

596 views
Skip to first unread message

HAHA afwf

unread,
Aug 21, 2020, 1:46:18 PM8/21/20
to chrome-debugging-protocol
I want to automatically clear all browser storage,

including localstorage, session storage, cookies. 

But the function Storage.clearDataForOrigin asks for the security origin, which I don't know.

whereas


don't seem to include local storage and session storage?


Andrey Kosyakov

unread,
Aug 21, 2020, 2:44:19 PM8/21/20
to HAHA afwf, chrome-debugging-protocol
There's no support for this at the moment. However, depending on your use case, you may find Target.createBrowserContext useful -- it will create a new profile similar to the incognito one, and all storages will be scoped to that profile and removed once the profile is destroyed.

Best regards,
Andrey.


--
You received this message because you are subscribed to the Google Groups "chrome-debugging-protocol" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chrome-debugging-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chrome-debugging-protocol/c1001ec3-a095-4dc4-b8ee-20a8cd9a5832n%40googlegroups.com.

boris.o...@ub.io

unread,
Aug 21, 2020, 2:53:35 PM8/21/20
to chrome-debugging-protocol
Hi,

I don't know if this is something experimental and/or unsupported, but sending `origin: '*'` worked for me for a couple of years now:

async clearBrowsingData() {
  await this.send('Storage.clearDataForOrigin', {
    origin: '*',
    storageTypes: 'all',
  });
  await this.send('Network.clearBrowserCookies');
}

Disclaimer: I'm not a Chromium contributor, so please use at your own risk.

HAHA afwf

unread,
Aug 23, 2020, 10:15:50 PM8/23/20
to chrome-debugging-protocol
Thank you for the reply, I will try.

My current solution is removing the ~/.config/google-chrome/Default folder. 
Reply all
Reply to author
Forward
0 new messages