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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Delete cookies and cache without destroying TChromium

Post Reply
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Delete cookies and cache without destroying TChromium

Post by thefunkyjoint »

Hi,

I need to delete the cookies (and the cache) without destroying already created TChromium components. To delete the cookies i manually delete the files inside the GlobalCEFApp.Cookies folder.

Problem is i can't do it in runtime because Windows will say the files are in use. To delete it, i need to close my app, go to the folder manually , delete the files and then open my app again.

Is there another to delete the files without closing my app ?

Thanks
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Re: Delete cookies and cache without destroying TChromium

Post by thefunkyjoint »

Just another info : even if i destroy TChromium, for some reason some files on Cookies dir keep locked ; the only way to delete them is closing the app.
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Delete cookies and cache without destroying TChromium

Post by salvadordf »

thefunkyjoint wrote: Wed Jan 03, 2018 3:10 pm Hi,

I need to delete the cookies (and the cache) without destroying already created TChromium components. To delete the cookies i manually delete the files inside the GlobalCEFApp.Cookies folder.

Problem is i can't do it in runtime because Windows will say the files are in use. To delete it, i need to close my app, go to the folder manually , delete the files and then open my app again.

Is there another to delete the files without closing my app ?

Thanks
You can delete the cookies with TChromium.DeleteCookies even if your app is running but as far as I know, there's no CEF3 function to clear the cache at run time.

There are some workarounds with similar effects :
  • Use TChromium.ReloadIgnoreCache to reload the web page ignoring the cache.
  • Create a new TChromium with a new Request Context that uses a different cache directory. Take a look at the TChildForm.FormShow procedure in the MDIBrowser demo.
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Delete cookies and cache without destroying TChromium

Post by salvadordf »

thefunkyjoint wrote: Wed Jan 03, 2018 3:17 pm Just another info : even if i destroy TChromium, for some reason some files on Cookies dir keep locked ; the only way to delete them is closing the app.
That's how CEF3 works. You can't delete those files before you destroy GlobalCEFApp.
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Re: Delete cookies and cache without destroying TChromium

Post by thefunkyjoint »

salvadordf wrote: Wed Jan 03, 2018 3:44 pm
thefunkyjoint wrote: Wed Jan 03, 2018 3:10 pm Hi,

I need to delete the cookies (and the cache) without destroying already created TChromium components. To delete the cookies i manually delete the files inside the GlobalCEFApp.Cookies folder.

Problem is i can't do it in runtime because Windows will say the files are in use. To delete it, i need to close my app, go to the folder manually , delete the files and then open my app again.

Is there another to delete the files without closing my app ?

Thanks
You can delete the cookies with TChromium.DeleteCookies even if your app is running but as far as I know, there's no CEF3 function to clear the cache at run time.

There are some workarounds with similar effects :
  • Use TChromium.ReloadIgnoreCache to reload the web page ignoring the cache.
  • Create a new TChromium with a new Request Context that uses a different cache directory. Take a look at the TChildForm.FormShow procedure in the MDIBrowser demo.
Hi Salvador,

Thanks for the answer. I could not find a 'DeleteCookies' method in TChromium... is it a new method for the recent versions ? I'm still on a couple of commits behind the most recent.
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Delete cookies and cache without destroying TChromium

Post by salvadordf »

thefunkyjoint wrote: Wed Jan 03, 2018 4:37 pmI could not find a 'DeleteCookies' method in TChromium... is it a new method for the recent versions ? I'm still on a couple of commits behind the most recent.
DeleteCookies was available in the first public release of CEF4Delphi almost a year ago.
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Re: Delete cookies and cache without destroying TChromium

Post by thefunkyjoint »

I found the function, called it but somehow when i close the app and open again, i'm still logged in the site , so the cookies were not deleted...
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Delete cookies and cache without destroying TChromium

Post by salvadordf »

Please, download CEF4Delphi again and try the new TChromium.DeleteCookies function.

Now it uses the right cookie manager in case you created a custom request context in your browsers.

https://www.briskbard.com/forum/viewtopic.php?f=8&t=251
Post Reply