Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static string login(string url, string username, string password)
- {
- HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
- string cookie = "";
- string values = "vb_login_username="+username+"&vb_login_password="+password
- + "securitytoken=guest&"
- + "cookieuser=checked&"
- + "do=login";
- req.Method = "POST";
- req.ContentType = "application/x-www-form-urlencoded";
- req.ContentLength = values.Length;
- CookieContainer a = new CookieContainer();
- req.CookieContainer = a;
- System.Net.ServicePointManager.Expect100Continue = false; // prevents 417 error
- using (StreamWriter writer = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII)) {writer.Write(values);}
- HttpWebResponse c = (HttpWebResponse)req.GetResponse();
- foreach (Cookie cook in c.Cookies){cookie = cookie + cook.ToString() + ";";}
- return cookie;
- }
- string cookie = login("forum.codecall.net/login.php?do=login", "username", "password"); // include http and www (I don't have 10 forum posts)
- Console.Write(cookie);
- Console.Read();
Add Comment
Please, Sign In to add comment