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

куки

Post by Kazann117 »

Доброго дня. Хотел узнать почему куки не сохраняются с первого раза например, я захожу в телеграм ввожу номер , захожу в аккаунт. делаю пару действий и закрываю форму с браузером, при повторном открытие формы с браузером мне приходится заново входить в аккаунт и так может быть 2-3 раза и потом он всё токи сохраняет куки


GlobalCEFApp.RootCache := disk+':\TG\Date\Accaunt\'+accaunt1;
TempContext := TCefRequestContextRef.New(disk+':\TG\Date\Accaunt\'+accaunt1,'',False, False, False, False);
{
// This would be a good place to set the proxy server settings for all your child
// browsers if you use a proxy
Chromium1.ProxyType := CEF_PROXYTYPE_FIXED_SERVERS;
Chromium1.ProxyScheme := psHTTP;
Chromium1.ProxyServer := '1.2.3.4';
Chromium1.ProxyPort := 1234;
Chromium1.ProxyUsername := '';
Chromium1.ProxyPassword := '';
}


Chromium1.CreateBrowser(CEFWindowParent1,disk+':\TG\Date\Accaunt\'+accaunt1, TempContext);
form1.Caption :='Браузер Real_Combain'+' : Создан '+accaunt1;
Kazann117
Posts: 41
Joined: Mon Jan 07, 2019 10:08 pm

Re: куки

Post by Kazann117 »

Good day. I wanted to find out why cookies are not saved the first time, for example, I go to telegram, enter the number, go to my account. I’m doing a couple of actions and closing the form with the browser, when I re-open the form with the browser I have to re-enter the account and this can be 2-3 times and then it saves all the currents cookies


GlobalCEFApp.RootCache: = disk + ': \ TG \ Date \ Accaunt \ '+ accaunt1;
TempContext: = TCefRequestContextRef.New (disk + ': \ TG \ Date \ Accaunt \' + accaunt1, '', False, False, False, False);
{
// Это было бы хорошим местом для установки параметров прокси-сервера для всех ваших дочерних
браузеров //, если вы используете прокси-сервер
Chromium1.ProxyType:
Chromium1.ProxyScheme: = psHTTP;
Chromium1.ProxyServer: = '1.2.3.4';
Chromium1.ProxyPort: = 1234;
Chromium1.ProxyUsername: = '';
Chromium1.ProxyPassword: = '';
}


Chromium1.CreateBrowser (CEFWindowParent1, disk + ': \ TG \ Date \ Accaunt \' + accaunt1, TempContext);
form1.Caption: = 'Браузер Real_Combain' + ': Создан' + accaunt1;
User avatar
salvadordf
Posts: 4572
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: куки

Post by salvadordf »

Hi,

GlobalCEFApp.RootCache has to be set before the GlobalCEFApp.StartMainProcess call in the DPR file.
Kazann117
Posts: 41
Joined: Mon Jan 07, 2019 10:08 pm

Re: куки

Post by Kazann117 »

Yes, I did, but the problem is cookies or the session is not saved immediately. or you have to wait a lot of time or you need to switch to your account 2-5 times
User avatar
salvadordf
Posts: 4572
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: куки

Post by salvadordf »

Perhaps a call to ICefCookieManager.FlushStore can fix that problem.

Read this for more details about that function :
https://magpcss.org/ceforum/apidocs3/pr ... llback%3E)
Kazann117
Posts: 41
Joined: Mon Jan 07, 2019 10:08 pm

Re: куки

Post by Kazann117 »

but how to use it is not entirely clear
Kazann117
Posts: 41
Joined: Mon Jan 07, 2019 10:08 pm

Re: куки

Post by Kazann117 »

man.FlushStore(nil);


gives an error and does not allow to close the form
User avatar
salvadordf
Posts: 4572
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: куки

Post by salvadordf »

If you use several request contexts then you need to get the cookie manager associated with each request context to call FlushStore.

To get the an ICookieManager instance call ICefRequestContext.GetCookieManager(nil).
You can get each request context by calling TChromium.Browser.Host.RequestContext when the browser is fully initialized.

I haven't tested this code but I guess it should be like this :

Code: Select all

  if Chromium1.Initialized then
    Chromium1.Browser.Host.RequestContext.GetCookieManager(nil).FlushStore(nil);
Kazann117
Posts: 41
Joined: Mon Jan 07, 2019 10:08 pm

Re: куки

Post by Kazann117 »

please tell me where to enter it I can not understand at all
Kazann117
Posts: 41
Joined: Mon Jan 07, 2019 10:08 pm

Re: куки

Post by Kazann117 »

TempContext := TCefRequestContextRef.New('c:\TG\Date\Accaunt\Accaunt 1','',False, False, False, False);

{ b.GetCookieManager(nil) ;
// This would be a good place to set the proxy server settings for all your child
// browsers if you use a proxy
Chromium1.ProxyType := CEF_PROXYTYPE_FIXED_SERVERS;
Chromium1.ProxyScheme := psHTTP;
Chromium1.ProxyServer := '1.2.3.4';
Chromium1.ProxyPort := 1234;
Chromium1.ProxyUsername := '';
Chromium1.ProxyPassword := '';
}


Chromium1.CreateBrowser(CEFWindowParent1,'c:\TG\Date\Accaunt\Accaunt 1', TempContext);
Post Reply