Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HttpWebRequest http = (HttpWebRequest)WebRequest.Create("URL");
- string cookie = string.Empty;
- string values = "vb_login_username=" + username + "&vb_login_password=" + password + "securitytoken=guest&" + "cookieuser=checked&" + "do=login";
- http.Method = "POST";
- http.ContentType = "application/x-www-form-urlencoded";
- http.ContentLength = values.Length;
- CookieContainer cookies = new CookieContainer();
- http.CookieContainer = cookies;
- ServicePointManager.Expect100Continue = false;
- using (var stream = new StreamWriter(http.GetRequestStream(), Encoding.ASCII))
- {
- stream.Write(values);
- }
- HttpWebResponse response = (HttpWebResponse)http.GetResponse();
- foreach (var c in response.Cookies)
- {
- cookie = cookie + c.ToString() + ";";
- }
- return cookie;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement