Page 1 of 2

куки

Posted: Fri Sep 06, 2019 6:46 am
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;

Re: куки

Posted: Fri Sep 06, 2019 6:47 am
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;

Re: куки

Posted: Fri Sep 06, 2019 8:18 am
by salvadordf
Hi,

GlobalCEFApp.RootCache has to be set before the GlobalCEFApp.StartMainProcess call in the DPR file.

Re: куки

Posted: Fri Sep 06, 2019 9:10 am
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

Re: куки

Posted: Sat Sep 07, 2019 8:47 am
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)

Re: куки

Posted: Mon Sep 09, 2019 1:30 pm
by Kazann117
but how to use it is not entirely clear

Re: куки

Posted: Mon Sep 09, 2019 1:40 pm
by Kazann117
man.FlushStore(nil);


gives an error and does not allow to close the form

Re: куки

Posted: Mon Sep 09, 2019 3:15 pm
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);

Re: куки

Posted: Mon Sep 09, 2019 4:22 pm
by Kazann117
please tell me where to enter it I can not understand at all

Re: куки

Posted: Mon Sep 09, 2019 4:23 pm
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);