Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Simple Cookie DCEF4

Post Reply
User avatar
salvadordf
Posts: 4072
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Simple Cookie DCEF4

Post by salvadordf »

Hi,

Use the CookieVisitor demo and modify the CookieVisitorProc procedure to save your cookie.
User avatar
danicarla2
Posts: 19
Joined: Mon Oct 01, 2018 6:01 pm
Location: Brazil

Re: Simple Cookie DCEF4

Post by danicarla2 »

Hi guys

Im able to create the cookies, but when I close the application it erases all the cookies...
How do I leave them stored?

I used the MiniBrowser demo.. but this also happens with CookieVisitor
User avatar
salvadordf
Posts: 4072
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Simple Cookie DCEF4

Post by salvadordf »

Set the GlobalCEFApp.cache property with a writable directory before the GlobalCEFApp.StartMainProcess call in the DPR file.
User avatar
danicarla2
Posts: 19
Joined: Mon Oct 01, 2018 6:01 pm
Location: Brazil

Re: Simple Cookie DCEF4

Post by danicarla2 »

In DPR file says "GlobalCEFApp.GlobalContext Initialized has to be TRUE before creating any browser"..

I try this:

Code: Select all

procedure TMiniBrowserFrm.FormShow(Sender: TObject);
begin
  ShowStatusText('Initializing browser. Please wait...');

  // WebRTC's IP leaking can lowered/avoided by setting these preferences
  // To test this go to https://www.browserleaks.com/webrtc
  Chromium1.WebRTCIPHandlingPolicy := hpDisableNonProxiedUDP;
  Chromium1.WebRTCMultipleRoutes   := STATE_DISABLED;
  Chromium1.WebRTCNonproxiedUDP    := STATE_DISABLED;

  // GlobalCEFApp.GlobalContext Initialized has to be TRUE before creating any browser
  // If it's not initialized yet, we use a simple timer to create the browser later.
  if not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
  GlobalCEFApp.cookies := 'C:\bin\blob_storage\';

end;
The directory "blob_storage" is created on debub MiniBrowser demo.. And I could use this directory to store cookies
Does this error occur because the directory permission is incorrect? or the code error?
User avatar
salvadordf
Posts: 4072
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Simple Cookie DCEF4

Post by salvadordf »

The code you posted belongs to a file with a PAS extension. To edit the DPR in your application, run Delphi and click on the "Project -> View Source" menu option.

You need to set GlobalCEFApp.cache before the GlobalCEFApp.StartMainProcess call as you can see here :
https://github.com/salvadordf/CEF4Delph ... owser2.dpr

That example shows a GlobalCEFApp.cookies property that is used when you need a different directory for cache and cookies but you need to set GlobalCEFApp.cache too.
User avatar
danicarla2
Posts: 19
Joined: Mon Oct 01, 2018 6:01 pm
Location: Brazil

Re: Simple Cookie DCEF4

Post by danicarla2 »

Thanks, this worked :)
Post Reply