public static void beginSession(string SessionId, string uid, string pass) { WebSession o = WebSession.login(uid, pass); if (o != null) { hs.Add(SessionId, o); } }
/*login method take username and password as input; select the * password for the username match it with password parameter; * return an instance of Webseesion if password match else * return a reference with null value * * It uses ExecuteScaler Method of Connection object; * */ public static WebSession login(string uid, string pass) { Connection conn; WebSession obj = null; string query = "select * from login where userid='" + uid + "' and password='******'"; conn = ConnectionPool.getConnection(); DataSet ds = conn.getDataSet(query, "password"); ConnectionPool.Free(conn); if (ds.Tables["password"].Rows.Count > 0) { obj = new WebSession(); obj.password = pass; obj.role = ds.Tables["password"].Rows[0]["role"].ToString(); obj.userid = uid; return(obj); } return(null); }