C
Cheung, Jeffrey Jing-Yen
I have a windows form application that generates a request, downloads an image, and waits the user
to enter in login info. Unfortunately, this image is dynamic and based on session data. I have
read documents on the CookieCollection property of HttpWebRequest. Currently, I have the
functionality in my code to be able to accept cookies, and return them upon a new HttpWebRequest;
however, upon further inspection of the returning HttpWebResponse.Cookies property, I notice that
the cookies that are supposed to be there regarding my session data are not returned (one such
cookie named, JSESSIONID). What other methods are there available to me to retrieve cookies that
would contain session data?
Here is a code snippet (please excuse the wordwrap)
Dim strURL As String = "https://www.thisurlisatest.com/"
Dim objHTTPRequest As HttpWebRequest = CType(WebRequest.Create(strURL), HttpWebRequest)
objHTTPRequest.CookieContainer = New CookieContainer()
Dim objHTTPResponse As HttpWebResponse = CType(objHTTPRequest.GetResponse(), HttpWebResponse)
Dim objReceiveStream As Stream = objHTTPResponse.GetResponseStream()
' I successfully retrieve the cookies here
m_Cookies = objHTTPResponse.Cookies
Dim objCookie As Cookie
For Each objCookie In m_Cookies
Console.WriteLine(objCookie.Name + "=" + objCookie.Value)
Next
' This only outputs this: language_pref=en_US
' There should be more cookies that contain session id data
Thanks in advance for any light you can shed on this matter,
Jeff Cheung
to enter in login info. Unfortunately, this image is dynamic and based on session data. I have
read documents on the CookieCollection property of HttpWebRequest. Currently, I have the
functionality in my code to be able to accept cookies, and return them upon a new HttpWebRequest;
however, upon further inspection of the returning HttpWebResponse.Cookies property, I notice that
the cookies that are supposed to be there regarding my session data are not returned (one such
cookie named, JSESSIONID). What other methods are there available to me to retrieve cookies that
would contain session data?
Here is a code snippet (please excuse the wordwrap)
Dim strURL As String = "https://www.thisurlisatest.com/"
Dim objHTTPRequest As HttpWebRequest = CType(WebRequest.Create(strURL), HttpWebRequest)
objHTTPRequest.CookieContainer = New CookieContainer()
Dim objHTTPResponse As HttpWebResponse = CType(objHTTPRequest.GetResponse(), HttpWebResponse)
Dim objReceiveStream As Stream = objHTTPResponse.GetResponseStream()
' I successfully retrieve the cookies here
m_Cookies = objHTTPResponse.Cookies
Dim objCookie As Cookie
For Each objCookie In m_Cookies
Console.WriteLine(objCookie.Name + "=" + objCookie.Value)
Next
' This only outputs this: language_pref=en_US
' There should be more cookies that contain session id data
Thanks in advance for any light you can shed on this matter,
Jeff Cheung