TChromium:如何保持会话存活 [英] TChromium : How to keep session alive
问题描述
使用DCEF3 TChromium时,如何使会话保持活动状态?
When using DCEF3 TChromium, how can i keep the session alive ?
例如,如果我去一个网站并登录,当我关闭我的应用程序并再次打开它时,我需要再次登录。我想让会话保持活动状态,就像使用Google Chrome一样。
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.
我尝试在我的应用程序 uses子句中添加 CefLib并设置'CefCache'类似于下面的代码,但是尽管我可以看到文件存储在'cookies'文件夹中,但在保持会话活动状态方面似乎没有什么区别:
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.
预先感谢。
推荐答案
官方DCEF3论坛中的一个人提供了以下经过测试和批准的解决方案!
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
这篇关于TChromium:如何保持会话存活的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!