Page 1 of 1

Delete cookies and cache without destroying TChromium

Posted: Wed Jan 03, 2018 3:10 pm
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

Re: Delete cookies and cache without destroying TChromium

Posted: Wed Jan 03, 2018 3:17 pm
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.

Re: Delete cookies and cache without destroying TChromium

Posted: Wed Jan 03, 2018 3:44 pm
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.

Re: Delete cookies and cache without destroying TChromium

Posted: Wed Jan 03, 2018 3:46 pm
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.

Re: Delete cookies and cache without destroying TChromium

Posted: Wed Jan 03, 2018 4:37 pm
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.

Re: Delete cookies and cache without destroying TChromium

Posted: Wed Jan 03, 2018 4:45 pm
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.

Re: Delete cookies and cache without destroying TChromium

Posted: Thu Jan 04, 2018 7:51 pm
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...

Re: Delete cookies and cache without destroying TChromium

Posted: Fri Jan 05, 2018 11:04 am
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