Link to home
Start Free TrialLog in
Avatar of shaneholmes
shaneholmes

asked on

Connecting to a website and maintaining a sesion.....?

I am using delphi 7 Enterprise.

I have a web page where I am a member of (I have a User ID & password). Is it possible to connect to that page from a Delphi Application and maintain a session with it. The reason I ask, is I want to retrieve info from the site for my application.

If So, what components do I use, and How?

This Question will start of with 125 points, but will be increased if its possible to accomplish the feat, and I get some code help!

sholmes
Avatar of DavidBirch2dotCom
DavidBirch2dotCom

I think you need to check on cpoy right issues...

but the problem is most likely to be the lack of a cookie - though quite how you would send it I am not sure
Avatar of shaneholmes

ASKER

Sorry, forgot to post the code im using....

Using Indy,

This is what I have right now:

var
 Params: TStringList;
begin
 Params := TStringList.Create;
 Params.Add('username=' + edtUserName.Text);
 Params.Add('password=' + edtPassword.Text);
 HTTP.Post('http://www.geocaching.com/login/default.aspx?RESET=Y&redir=http%3a%2f%2fwww.geocaching.com%2fDefault.aspx', Params);
 Memo.Text := HTTP.Get('http://www.geocaching.com/Default.aspx');
 Params.Free;
end;

sholmes
Hmm.. Isn't it possible to read headers (of homepage) with Indy components? And what about cookies (session variable is usually stored as cookie)?
I don't have Indy, so I can't provide you with exact code.
Avatar of Eddie Shipman
Shane, seeing that it is an ASP.Net site, I would suspect that they are using ASP SessionIDs which can be very
tricky. When you maneuver in the site do you see your sessionid at the end of the URLs? If not, then
they may be using a cookie.

I'd get a packet sniffer to see exactly what they are sending, get a good one here:
http://www.ethereal.com/
Here is what the end of each url looks like:

This is the page url

http://www.geocaching.com/

This is the login page url

http://www.geocaching.com/login/default.aspx?RESET=Y&redir=http%3a%2f%2fwww.geocaching.com%2fDefault.aspx


This is the url after a successful login

http://www.geocaching.com/Default.aspx


A successful loging would have a different page then a unsuccessful login


sholmes
ASKER CERTIFIED SOLUTION
Avatar of Eddie Shipman
Eddie Shipman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
k - i'll try it and see what i can do woth it.

sholmes
What did you find out, Shane?