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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

куки

Kazann117
Posts: 41
Joined: Mon Jan 07, 2019 10:08 pm

Re: куки

Post by Kazann117 »

this site uses not only cookies but also cache and session

when you’re on the site for 20-40 seconds, everything is fine, but when you log in and immediately close the form, you don’t save anything
User avatar
salvadordf
Posts: 4565
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: куки

Post by salvadordf »

Kazann117 wrote: Mon Sep 09, 2019 4:22 pm please tell me where to enter it I can not understand at all
Add it before the Chromium1.CloseBrowser call.
Kazann117
Posts: 41
Joined: Mon Jan 07, 2019 10:08 pm

Re: куки

Post by Kazann117 »

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if Chromium1.Initialized then
Chromium1.Browser.Host.RequestContext.GetCookieManager(nil).FlushStore(nil);
Chromium1.CloseBrowser(True);
end;


everything exactly has to wait 10-40 seconds so that the session cookie cache is saved even though the folder shows that it is saved
Kazann117
Posts: 41
Joined: Mon Jan 07, 2019 10:08 pm

Re: куки

Post by Kazann117 »

проблема так и не решилась совсем также всё
User avatar
salvadordf
Posts: 4565
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: куки

Post by salvadordf »

I'm sorry but as far as I know there's nothing more you can do to store the cookies.

CEF4Delphi is limited by the CEF API at the time. If there's an issue upstream (CEF or Chromium) then we can only report it.
Kazann117
Posts: 41
Joined: Mon Jan 07, 2019 10:08 pm

Re: куки

Post by Kazann117 »

все сайты сохраняют куки с первого раза а вот телеграм не хочет
User avatar
salvadordf
Posts: 4565
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: куки

Post by salvadordf »

As far as I know, the CEF API only has one way to flush the cookies to the disk using the "FlushStore" procedure.

If that doesn't work then I'm afraid I can't help you. :oops:
Kazann117
Posts: 41
Joined: Mon Jan 07, 2019 10:08 pm

Re: куки

Post by Kazann117 »

напишите пожалуйста как сделать это правильно полностью с процедурой пожалуйста
User avatar
salvadordf
Posts: 4565
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: куки

Post by salvadordf »

Please download CEF4Delphi again from GitHub.

There is a new TChromium.FlushCookieStore function to flush the cookies easily.

The MiniBrowser demo shows how to use it asynchronously with the TChromium.OnCookiesFlushed event but if you need to flush the cookies immediately then you can call TChromium.FlushCookieStore(True). In that case the TChromium.OnCookiesFlushed event will not be triggered.

If you need to flush the cookies before closing the MiniBrowser demo then you would have to replace TMiniBrowserFrm.FormCloseQuery with this :

Code: Select all

procedure TMiniBrowserFrm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  CanClose := FCanClose;

  if not(FClosing) then
    begin
      Chromium1.FlushCookieStore; // By default it flushes the cookies immediately and you don't need to pass a TRUE parameter.
      FClosing := True;
      Visible  := False;
      Chromium1.CloseBrowser(True);
    end;
end;
Post Reply