TChromium : How to keep session alive

杀马特。学长 韩版系。学妹 提交于 2020-01-16 07:04:29

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/34615234/tchromium-how-to-keep-session-alive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!