delphirules
delphirules

Reputation: 7390

TChromium : How to keep session alive

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

For instance, if i go to a web-site and login on it, when i close my app and open it again, i need to login again. I want to keep the session alive, just like it would be if i use Google Chrome.

I tried to add 'CefLib' on my app 'uses' clause and set 'CefCache' like the code below, but although i can see files being stored on 'cookies' folder, it seems to make no difference in keeping the session alive :

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.

Upvotes: 1

Views: 1966

Answers (1)

delphirules
delphirules

Reputation: 7390

A guy form the official's DCEF3 forum provided the solution below, 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

Upvotes: 2

Related Questions