BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Getting Cookies from All Running IE Instances

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Johnnie Norsworthy
Guest





PostPosted: Tue May 08, 2007 8:12 am    Post subject: Getting Cookies from All Running IE Instances Reply with quote



I need to be able to iterate though all instances of IE and examine the
underlying OleObject.Document.Cookie to determine if a web site has
authorized so I don't try to log in again, but instead use the existing
credentials in the cookie.

I saw some code that might help, but I do not know how ot get to the
cookies:

var
x : Integer;
ShellWindows : IShellWindows;
Browser : IWebBrowser2;
IE: TInternetExplorer;
begin
Result := '';
{ IShellWindows can provide interfaces to open browser windows. }
ShellWindows := CoShellWindows.Create;
for x := 0 to Pred(ShellWindows.Get_Count) do
ShowMessage( ( ShellWindows.Item( x ) as IWebBrowser2 ).LocationURL );
Browser := ( ShellWindows.Item( 0 ) as IWebBrowser2 );


Any help would be appreciated. Thanks!

-Johnnie
Back to top
Johnnie Norsworthy
Guest





PostPosted: Tue May 08, 2007 8:12 am    Post subject: Re: Getting Cookies from All Running IE Instances Reply with quote



I found a solution to this. I do some extra tests in my real application
code, but this is the technique I used (for future web searchers).

-Johnnie

function FindCookies: string;
var
ShellWindow: IShellWindows;
WB: IWebbrowser2;
spDisp: IDispatch;
iDoc: IHTMLDocument2;
i: Integer;
begin
Result := '';
ShellWindow := CoShellWindows.Create;
for i := 0 to ShellWindow.Count do
begin
spDisp := ShellWindow.Item(i);
if spDisp = nil then Continue;
spDisp.QueryInterface(iWebBrowser2, WB);
if WB <> nil then
begin
WB.Document.QueryInterface(IHTMLDocument2, iDoc);
Result := iDoc.cookie;
end;
end;
end;
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.