1

In CEF4Delphi it is possible to maintain the browser session with

GlobalCEFApp.PersistSessionCookies := True;
GlobalCEFApp.Cache := 'cache_folder';

thanks to this, one can keep embeed browser logged in, for example, mail. Unfortunately, this solution saves the entire cache of the browser, including attachments etc., which makes the cache folder very large after a while. In the previous version (CEF3) was an option to manage only a component that took up very little on the disk:

CookieManager := TCefCookieManagerRef.Global(nil);
CookieManager.FlushStore(nil);

but I have not found a similar solution for CEF4, while the command

GlobalCEFApp.PersistUserPreferences := True;
GlobalCEFApp.UserDataPath := 'User_Data_folder';

does not save any information in the created folder at all.

Is there any method to keep logging only without saving the entire cache? Or maybe some philosophy which i did not figured out yet, for example deleting some specific folders with a saved cache?

Note: My version of CEF4Delphi uses CEF 86.0.21 which includes Chromium 86.0.4240.183; i'm using TChromium component.

kwadratens
  • 187
  • 15
  • 1
    CEF supports sending DevTools commands for which there are a few options, you can disable caching https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-clearBrowserCache no idea if CEF4Delphi exposes the relevant API yet. – amaitland Nov 10 '20 at 02:28

1 Answers1

0

If you are using Global Cookie manager you should also set GlobalCEFApp.PresistSessionCookies to True

CEF4Delphi also has two properties which you can use to delet od cache or cookies upon CEF application initialization. These are DeleteCache and DeleteCookies.

SilverWarior
  • 7,372
  • 2
  • 16
  • 22
  • Are you sure the session cookies should be presisted? – Andreas Rejbrand Nov 07 '20 at 17:11
  • @AndreasRejbrand Pretty sure. There are three ways websites keeps session information. Either they use hidden field integrated into a web page, store session id as part of URL, or store session information in a cookie. The later is the most common approach and the only that allows retaining session information after closing the browser. So yeah session cookies should be persisted otherwise you lose session information. – SilverWarior Nov 08 '20 at 02:43
  • I don't doubt that. I was more concerned about the difference between "presisted" and "persisted"! :) – Andreas Rejbrand Nov 08 '20 at 07:48
  • 1
    Note that sessions are generally short-lived on the server, so even if you persist the session cookie and come back a few hours later, the session will have probably expired. – Olivier Nov 08 '20 at 09:03
  • I'm sorry, but none of this solutions works. GlobalCEFApp.DeleteCache := True; deletes all browser information - with interested here login status; DeleteCookies := True does nothing to cache (and also deletes login information). – kwadratens Nov 09 '20 at 07:10