Hi,
I'm trying to use the following code:
HttpWebRequest webRequest = WebRequest.Crea te(LOGIN_URL) as HttpWebRequest;
webRequest.Cook ieContainer = new CookieContainer ();
HttpWebResponse webResponse = (HttpWebRespons e) webRequest.GetR esponse();
This code let me get the cookie (cookie PHPSESSID) I need, from
webResponse.
I will need this cookie to get the page that i really need.
Now I will copy the cookie to the HttpWebRequest that i will use to get the
real needed page:
HttpWebRequest httpWebRequestL ogin =
HttpWebRequest. Create(LOGIN_UR L_LOGIN) as HttpWebRequest;
httpWebRequestL ogin.CookieCont ainer = new CookieContainer ();
//note: webResponse.Coo kies[0] have the PHPSESSID cookie (i know this)
httpWebRequestL ogin.CookieCont ainer.Add(webRe sponse.Cookies[0]);
httpWebRequestL ogin.Method="PO ST";
httpWebRequestL ogin.ContentTyp e="applicatio n/x-www-form-urlencoded";
StreamWriter requestWriter = new StreamWriter
(httpWebRequest Login.GetReques tStream());
requestWriter.W rite(data);
requestWriter.C lose();
//lets try to get the page
HttpWebResponse httpWebResponse Login =
(HttpWebRespons e) httpWebRequestL ogin.GetRespons e();
The page didn't come out! Because the cookie PHPSESSID wasn't on the
httpWebRequestL ogin, I think!
So what in the name of LORD am I doing wrong (in the process of copying the
cookie from the webResponse to the httWebRequestLo gin)?
Please help me...
Thanks on advance,
o.f
I'm trying to use the following code:
HttpWebRequest webRequest = WebRequest.Crea te(LOGIN_URL) as HttpWebRequest;
webRequest.Cook ieContainer = new CookieContainer ();
HttpWebResponse webResponse = (HttpWebRespons e) webRequest.GetR esponse();
This code let me get the cookie (cookie PHPSESSID) I need, from
webResponse.
I will need this cookie to get the page that i really need.
Now I will copy the cookie to the HttpWebRequest that i will use to get the
real needed page:
HttpWebRequest httpWebRequestL ogin =
HttpWebRequest. Create(LOGIN_UR L_LOGIN) as HttpWebRequest;
httpWebRequestL ogin.CookieCont ainer = new CookieContainer ();
//note: webResponse.Coo kies[0] have the PHPSESSID cookie (i know this)
httpWebRequestL ogin.CookieCont ainer.Add(webRe sponse.Cookies[0]);
httpWebRequestL ogin.Method="PO ST";
httpWebRequestL ogin.ContentTyp e="applicatio n/x-www-form-urlencoded";
StreamWriter requestWriter = new StreamWriter
(httpWebRequest Login.GetReques tStream());
requestWriter.W rite(data);
requestWriter.C lose();
//lets try to get the page
HttpWebResponse httpWebResponse Login =
(HttpWebRespons e) httpWebRequestL ogin.GetRespons e();
The page didn't come out! Because the cookie PHPSESSID wasn't on the
httpWebRequestL ogin, I think!
So what in the name of LORD am I doing wrong (in the process of copying the
cookie from the webResponse to the httWebRequestLo gin)?
Please help me...
Thanks on advance,
o.f
Comment