TWebBrowser and HttpOnly cookie

0

How to get the HttpOnly cookie from TWebBrowser? when logging into a page through IE, Firefox, or chrome I see the following cookie:

Cookie: _ga = GA1.3.2133370562.1518083464; _gid = GA1.3.1396320410.1518629322; _gat = 1; JSESSIONID = Qfh5hG0TWtphv6N2B6MT57d561RQzGqRLCb0B1322Kz49pp1R44g! 1012588258! NONE

While TWebBroser shows me only

Cookie: _ga = GA1.3.2133370562.1518083464; _gid = GA1.3.1396320410.1518629322; _gat = 1

    
asked by anonymous 15.02.2018 / 00:42

1 answer

0

After a long search I found the solution, go to whoever needs it:

const
  INTERNET_COOKIE_HTTPONLY = 8192;
var
  hModule: THandle;
  lp: Pointer;
  InternetGetCookieEx: function(lpszUrl, lpszCookieName, lpszCookieData
    : PAnsiChar; var lpdwSize: DWORD; dwFlags: DWORD; lpReserved: pointer)
    : BOOL; stdCall;
  CookieSize: DWORD;
  CookieData: PAnsiChar;
begin
  LoadLibrary('wininet.dll');
  hModule := GetModuleHandle('wininet.dll');
  if hModule <> 0 then
  begin
    @InternetGetCookieEx := GetProcAddress(hModule, 'InternetGetCookieExA');
    if @InternetGetCookieEx <> nil then
    begin
      CookieSize := 1024;
      Cookiedata := AllocMem(CookieSize);
      if InternetGetCookieEx(PAnsiChar(AnsiString(host)), nil, Cookiedata, CookieSize, INTERNET_COOKIE_HTTPONLY, nil) then
      result:=cookiedata;
      FreeMem(Cookiedata);
    end;
  end;
end;
    
15.02.2018 / 13:07