delphi - How to set different cookies for different instances of Chromium embedded browser -
I am working on an app that requires multiple embedded instances and each instance is different Requires login on the same external site with authentication details.
I am using CEF (Chromium embedded framework) in Delphi, I have a folder on which I store cookies for different instances of my browsers, so I have this code The first unit has
process TForm2.Button1Click (Sender: Tubect); Start form 33: = Tform3.Create (zero); Form33.Show; End;
When Form 33 was created
Process TForm3.FormCreate (Sender: Tubect); Various Cookie Managers: ICFQKY Manager; Folder: string; Start at random; Chromium1.SetBrowserID (Random (1244)); Folder: = Randomtext (5); If DirectoryExists (folder) = False then MkDir (folder); Cookie Manager: = Tcefkkimenager Global; Path: = ExtractFilePath (Application.ExeName) + folder; Cookie Manager. Setup Path (path, true); End;
The problem is that when I open two or more instances of Form 33, then every browser can not have one for every browser 33 A specific cookie ... < / P>
A new manager for each instance by you TCefCookieManagerRef.New (path)
You should create and return the store reference in some private area of your form and then you result
on OnGetCookieManager
event method Need to revert archived reference:
type TForm1 = class (TForm) Chromium 1: T Chromium; Process formulas (sender: toobject); Process Chromium 1GetCookieManager (Sender: Tubect; Out Result: ICefCookieManager); Private FCookieManager: ICefCookieManager2; End; TForm1.FormCreate (Sender: TObject) implementation process; Start FCookieManager: = TCefCookieManagerRef.New ('C: \ UniquePathToTheCookieStorage'); End; Process TForm1.Chromium1GetCookieManager (Sender: Tubect; Out Result: ICefCookieManager); Start the result: = FCookieManager; End;
Comments
Post a Comment