I know how to get the source code but the website that I have been working on uses PHP session, this mean that you will need to login(which I have) and use the session ID that the server send back. How do I do this?
+2
A:
Assuming you meant Session, you'll need CookieContainer:
CookieContainer cookies = new CookieContainer();
HttpWebRequest getRequest = (HttpWebRequest)WebRequest.Create(someSite);
getRequest.CookieContainer = cookies;
getRequest.Method = "GET";
HttpWebResponse form = (HttpWebResponse)getRequest.GetResponse();
using (StreamReader response =
new StreamReader(form.GetResponseStream(), Encoding.UTF8))
{
formPage = response.ReadToEnd();
}
You first make a GET request to server and it'll return your SessionID in a cookie. If you need to make new requests to same server, you must pass it through and server will identify you as a returning user.
Rubens Farias
2009-12-11 10:20:25
Thanks, I spelled it wrong sorry.
Jonathan Shepherd
2009-12-11 10:21:24
And how do I pass it to the next request? Sorry I'm a bit confuse here.
Jonathan Shepherd
2009-12-11 10:23:01
`newRequest.CookieContainer = cookies;` will do the trick
Rubens Farias
2009-12-11 10:23:58
Got it working thanks.
Jonathan Shepherd
2009-12-11 10:27:37