Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to make WebBrowser control share cookies with HttpWebRequest?

is there a way to make the WebBrowser control in C#.NET and requests made by HttpWebRequest share cookies?

E.g. if a request is made programmatically with HttpWebRequest and then the HttpWebResponse sets a cookie, is there a way to make sure this is also set in the WebBrowser control?

and likewise, if the user navigates with the WebBrowser control and a cookie is set, is there a way to ensure the CookieContainer for the HttpWebRequest is also updated?

Thanks for any help!

like image 931
Jimmy Avatar asked Jul 17 '11 11:07

Jimmy


1 Answers

You'd need to synchronize the cookies manually using the InternetSetCookieEx / InternetGetCookieEx APIs, and this would require that you know all of the URLs of all of the subdownloads used by the page in question.

You also need to pass the INTERNET_COOKIE_HTTPONLY flag to ensure that HTTPONLY cookies are seen by your application.

like image 173
EricLaw Avatar answered Oct 15 '22 16:10

EricLaw