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.

Cookies with Proxy

Post Reply
Chinyaev
Posts: 38
Joined: Mon Mar 13, 2017 3:23 pm

Cookies with Proxy

Post by Chinyaev »

Hello!

When use proxy, cookies set with timeout.

Image

proxy setting:

Code: Select all

begin
  ChromiumWindow1.ChromiumBrowser.ProxyType:=3;
  ChromiumWindow1.ChromiumBrowser.ProxyServer:=sEdit1.Text;
  ChromiumWindow1.ChromiumBrowser.ProxyPort:=StrToInt(Edit1.Text);
  ChromiumWindow1.ChromiumBrowser.ProxyUsername:=Edit2.Text;
  ChromiumWindow1.ChromiumBrowser.ProxyPassword:=Edit3.Text;
  //  This also does not work right away.
  //  ChromiumWindow1.ChromiumBrowser.CustomHeaderName:='Cookie';
  //  ChromiumWindow1.ChromiumBrowser.CustomHeaderValue:='test=1;';
  ChromiumWindow1.ChromiumBrowser.OnBeforeResourceLoad:=OnBeforeResourceLoad;  

  ChromiumWindow1.LoadURL('https://google.com');
end;
insert header:

Code: Select all

procedure TForm1.OnBeforeResourceLoad(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame;  const request: ICefRequest; const callback: ICefRequestCallback; out Result: TCefReturnValue);
Var
  map: ICefStringMultimap;
begin
  map := TCefStringMultimapOwn.create;
  request.GetHeaderMap(map);
  map.Append('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36');
  map.Append('Cookie', 'test=2;');
  request.SetHeaderMap(map);

  Result := RV_CONTINUE;
end;
And, the User-Agent is set without timeout.
User avatar
salvadordf
Posts: 4042
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Cookies with Proxy

Post by salvadordf »

I'll take a look as soon as I can. Maybe it's related to the way preferences (proxy settings) are updated.
User avatar
salvadordf
Posts: 4042
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Cookies with Proxy

Post by salvadordf »

Hi :

Download the latest version of CEF4Delphi with the corresponding binaries here :
32bit -> http://opensource.spotify.com/cefbuilds ... 32.tar.bz2
64bit -> http://opensource.spotify.com/cefbuilds ... 64.tar.bz2

Now you have a new function to update the preferences (proxy settings) in that moment : TChromium.UpdatePreferences
You can try it in the minibrowser demo. It has a new preferences form with the proxy settings and the custom header values.

If you still have problems with cookies maybe you should use the global cookie manager with the ICefCookieManager.SetCookie function.
Take a look at TChromium.SetCMStoragePath for an example about ICefCookieManager.
Chinyaev
Posts: 38
Joined: Mon Mar 13, 2017 3:23 pm

Re: Cookies with Proxy

Post by Chinyaev »

Thank you, but it isn't worked for me.
I decided it this way: ChromiumWindow1.ChromiumBrowser.LoadURL('http://google.com'); // browser do redirect on https://www.google.ru/ and set cookie. But this decision is not for everything.
Post Reply