Requires: System.Net; & System.IO;
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;
}
It returns the cookie data so when loading other pages of the site, you can just send the cookies and stay logged in with the headers.add("cookie", cookie) method.
And an example;
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();
This has only been tested on vBulletin 3.x versions.


Sign In
Create Account


Back to top









