Is there a command on CEF4Delphi to clear just the local storage (not cookies) of the current url ?
I mean that part on Devtools :
https://ibb.co/QYTmQR6
Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
Clear local storage ?
- salvadordf
- Posts: 4580
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Clear local storage ?
Yes. You can call TChromiumCore.ClearDataForOrigin with these parameters :
https://chromedevtools.github.io/devtools-protocol/tot/Storage/#method-clearDataForOrigin
This is an asynchronous function and you have to wait for the TChromiumCore.OnDevToolsMethodResult event to know the result.
- aOrigin : Security origin. An asterisk * means all origins.
- aStorageTypes :
- cdstAppCache : app cache
- cdstCookies : cookies
- cdstFileSystems : file systems
- cdstIndexeddb : indexed db
- cdstLocalStorage : local storage
- cdstShaderCache : shader cache
- cdstWebsql : websql
- cdstServiceWorkers : service workers
- cdstCacheStorage : cache storage
- cdstAll : all of the above.
https://chromedevtools.github.io/devtools-protocol/tot/Storage/#method-clearDataForOrigin
This is an asynchronous function and you have to wait for the TChromiumCore.OnDevToolsMethodResult event to know the result.
-
- Posts: 513
- Joined: Thu Aug 10, 2017 12:40 pm
Re: Clear local storage ?
I've made some tests and looks like i need to call the function like this :
ClearDataForOrigin('cdstLocalStorage',cdstLocalStorage);
Passing two parameters otherwise it will delete everything, including cookies. Is this correct ?
ClearDataForOrigin('cdstLocalStorage',cdstLocalStorage);
Passing two parameters otherwise it will delete everything, including cookies. Is this correct ?
- salvadordf
- Posts: 4580
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Clear local storage ?
Use a URL as origin in the first parameter like this :
If you navigate to https://www.google.com you will see an entry in the local storage. The previous code deletes that entry and leaves the cookies unchanged.
Code: Select all
TChromiumCore.ClearDataForOrigin('https://www.google.com', cdstLocalStorage);
-
- Posts: 513
- Joined: Thu Aug 10, 2017 12:40 pm
Re: Clear local storage ?
Now i understood, the first parameter is the url. Thanks !