用户登陆信息 我保存到了session,我想把session验证写成一个类 在需要验证直接调用类来验证用户是否合法,最好能给出代码
————————————————————————————————
附:用户登陆代码
private void btnLogon_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
if(Page.IsValid)
{
if(IsUserIdentify())
{
Response.Redirect("mian.aspx");
}
else
{
lblMessage.Text="用户名/密码错误";
}
}
dr.Close();
}
private bool IsUserIdentify()
{
string sUsername=Request.Form["Username"];
string sUserPass=Request.Form["Password"];
string Username = business.Sqlchenck.FunStr(sUsername);
string UserPass = business.Sqlchenck.FunStr(sUserPass);
string sql = "select id,UserName,UserPass from Admin where UserName = '" + Username + "' and UserPass = '" + UserPass + "' and Lock='0'";
dr = new CReader(sql);
if(dr.Read())
{
Session["id" ] = dr["id"].ToString();
Session["UserName"] = dr["UserName"].ToString();
Session["UserPass"] = dr["UserPass"].ToString();
return true;
}
else
{
return false;
}