TChromium: how to keep the session alive

When using DCEF3 TChromium, how can I keep the session alive?

For example, if I go to a website and login, when I close my app and reopen it, I need to login again. I want to keep the session alive as if I were using Google Chrome.

I tried to add "CefLib" to my "uses" application and set "CefCache" like the code below, but although I can see the files stored in the "cookie" folder, it doesn't seem to make any difference, the session is live:

program Project1;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1},
  ceflib in 'C:\app\dcef\src\ceflib.pas';

{$R *.res}

begin
  CefCache := 'cookies';
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

      

Thanks in advance.

+1


source to share


1 answer


The guy from DCEF3 official forum provided the below solution, tested and approved!



CookieManager: ICefCookieManager;

FormCreate:
begin
   CookiesPath := ExtractFilePath(Application.ExeName) + 'cookies';
   CookieManager := TCefCookieManagerRef.Global(nil);
   CookieManager.SetStoragePath(CookiesPath, True, nil);
end;

FormClose:   
begin
  CookieManager.FlushStore(nil);
end

      

+2


source







All Articles