I'm using CEF 4. There are two instances of chromium on the form, they both use the same settings:
procedure CreateGlobalCEFApp;
var
inicef: Tinifile;
begin
GlobalCEFApp := TCefApplication.Create;
GlobalCEFApp.LogFile := 'debug.log';
GlobalCEFApp.LogSeverity := LOGSEVERITY_INFO;
GlobalCEFApp.cache := 'cache';
GlobalCEFApp.EnablePrintPreview := True;
path := ExtractFilePath(ParamStr(0));
GlobalCEFApp.DisableFeatures := 'WinUseBrowserSpellChecker';
inicef := Tinifile.Create(path '\settings.ini');
GlobalCEFApp.UserAgent := Pchar(inicef.ReadString('Chrome', 'UserAgent', ''));
inicef.free;
end;
How can I make each instance use a different path for cookies? I need to log in with two accounts to the same site.
CodePudding user response:
From a previous question it seems that CEF stores the cookie location in the cache path. You can set the GlobalCEFApp.cache
property to a different location for each instance.
CodePudding user response:
The cookies are inside the cache directory and you need to create browsers using different cache directories if you want them to be independent.
Create a new request context with a different cache directory and pass it when you call TChromium.CreateBrowser to create the second browser.
The MDIBrowser demo shows how to create new independent browsers here.
Read the code comments in that demo. CEF requires that all the cache directories must be a subdirectory of the GlobalCEFApp.RootCache directory.
CEF can't be initialized more than once per process. Create only one GlobalCEFApp instance and then create all the browsers that you need using MDI forms, tabs, frames, etc. There are CEF4Delphi demos showing how to do all of them.