AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke TidCookieManager & Redirects
Thema durchsuchen
Ansicht
Themen-Optionen

TidCookieManager & Redirects

Ein Thema von Ryzinski · begonnen am 7. Nov 2012
Antwort Antwort
Ryzinski

Registriert seit: 2. Okt 2012
38 Beiträge
 
#1

TidCookieManager & Redirects

  Alt 7. Nov 2012, 14:09
I get cookie from InternetGetCookieEx on DownloadComplete WebBrwoser. When trying to login to hotmail it get's through but then get's redirected. Even though Gmail works. I am trying to figure out a universal solution to transfer Authenication from WebBrowser to IdCookieManager for Web Parsing.

Cookies aswell as redirects are enabled on IdHTPP.

Zitat:
Cookies must be allowed
Your browser is currently set to block cookies. Your browser must allow cookies before you can use Windows Live ID.
Delphi-Quellcode:
 function GetCookie(host: string): string;
    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;

procedure EmbeddedWB1DocumentComplete(ASender: TObject; const pDisp: IDispatch;
  var URL: OleVariant);
var
  document: IHTMLDocument2;
  cookies: TStringList;
  uri: TIdURI;
begin
  document := EmbeddedWB1.Document as IHTMLDocument2;
  cookies := TStringList.Create;
  try
    cookies.Delimiter:=';';
    //cookies.DelimitedText:=GetCookie(document.url);
    cookies.DelimitedText:=document.cookie;
    uri := TIdURI.Create(document.url);
    try
      IdCookieManager1.AddServerCookies(cookies,uri);
      EmbeddedWB1.LoadFromString(http.Get(document.url));
    finally
      uri.Free;
    end;
  finally
    cookies.Free;
  end;
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:01 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz