Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XMLHTTP login / browse to page?

Status
Not open for further replies.

tlhawkins

Programmer
Dec 28, 2000
797
US
I need to pull some dynamic content off a site that I have a login to. The login is a regular form login and the session, on the remote server, must be tracked via a session id in a cookie because I never see the session id on the URI anywhere.

I can post the login credentials via a standard HTTP POST using the XMLHTTP object and get the menu page back as a successful login. Then I need to be able to access other pages on the site without loosing my login. If I try just grabbing another page it just gives me the login page again.

Is there someway to do this?
Thanks

Travis Hawkins
 
Along with the content, the XMLHTTP object also gives you access to the headers that are returned from your web request. These headers will include one or more cookie values that you need to pass back with your requests. As you "browse" through the site these may change, so it's a good idea to try and update them for each request.

Try looking at the following example:

What he has done is basically build a function that does each of his calls, updating his collection of cookies each time he receives a response. He has some additional pieces in theer you might not need, as it look slike he's scrap a remote site so that he can redisplay the content as it originally looked, but the logic should be useful for what your doing.

-T

 
Thanks for responding and I think we're on the right track. It seems like there must be something I need to return with the next request but it's an Apache server that I'm hitting. Here is the full header response:

Date: Fri, 26 Jan 2007 18:38:27 GMT Server: Apache/2.0.52 (Red Hat) Expires: -1 P3P: CP="NOI DSP LAW NID CUR TAIa CONi OUR STP UNI STA" Keep-Alive: timeout=15, max=2499 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html;charset=UTF-8

I don't see any cookies in there. I've tried returning the CP="NOI DSP LAW NID CUR TAIa CONi OUR STP UNI STA" part but that had no effect.

Is there some other way that an Apache server could be tracking my session?

Thanks

Travis Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top