Page 1 of 1

CEF4Delphi cookies

Posted: Sun Dec 05, 2021 12:12 pm
by amiran6543
Hello, please help with cookies, how to make different cookies for each element of chromium???

Re: CEF4Delphi cookies

Posted: Sun Dec 05, 2021 1:38 pm
by salvadordf
Hi,

You need to create independent browsers.

The MDIBrowser demo has all the code you need for that. Build it and check the "Create a new request context for new browsers" checkbox to create independent browsers.

This is the function that creates each child browser with a new request context to make them independent :
https://github.com/salvadordf/CEF4Delphi/blob/668e4ab25fc6c305ec447d10c64e742d29f09984/demos/Delphi_VCL/MDIBrowser/uChildForm.pas#L218

Re: CEF4Delphi cookies

Posted: Sun Dec 05, 2021 4:40 pm
by amiran6543
Thank you, I saw this example, but I didn't understand how to do it exactly by clicking on the button, for example, I click on one of the many buttons and a website opens with saved cookies and cookies, and so different cookies for different buttons with the chromium component!

Re: CEF4Delphi cookies

Posted: Mon Dec 06, 2021 2:40 pm
by salvadordf
When you check the "Create a new request context for new browsers" checkbox and you create a new browser it will have a unique request context with a different cache folder.

Each cache folder has a different database with the web browser cookies.

This means that the cookies on one browser will not be visible by the rest of the browsers because each browser uses a different cache.

Re: CEF4Delphi cookies

Posted: Mon Dec 06, 2021 3:28 pm
by amiran6543
I understand you, well, for example, I want to do this without opening another form, all in one form, by pressing a button
as I understand it, the code should look like this:

procedure TMainForm.Button1Click(Sender: TObject);
var
TempContext : ICefRequestContext;
TempCache : string;
begin

TempCache := GlobalCEFApp.RootCache + '\cache' + inttostr(MainForm.BrowserCount);

TempContext := TCefRequestContextRef.New(TempCache, '', '', False, False, False) ;

Chromium1.DefaultURL := Edit1.Text;
Chromium1.CreateBrowser(CEFWindowParent1, '', TempContext);
end;
But swears on a line : TempContext := TCefRequestContextRef.New(TempCache, '', '', False, False, False) ;
Error E2034 Too many actual parameters
I would be grateful if you can help!!

Re: CEF4Delphi cookies

Posted: Tue Dec 07, 2021 8:13 am
by salvadordf
There were some changes in the API recently that modified the parameters in that function.

If you see that error it means that Delphi is still using some old compiled units.
Sometimes Delphi keeps outdated DCU and BPL files that could cause this issue.
Uninstall CEF4Delphi and install it again. Follow this guide :
https://www.briskbard.com/forum/viewtopic.php?f=8&t=772#p3481

Re: CEF4Delphi cookies

Posted: Tue Dec 07, 2021 9:20 am
by amiran6543
Thank you very much, it helped!