Ejemplo n.º 1
0
    protected void Login_Click(object sender, EventArgs e)
    {
        StudentInfo student = bllStudent.GetByName(Username.Text.ToString());

        if (student != null && Password.Text.ToString() == student.Stu_Password)
        {
            HttpCookie cookie = new HttpCookie("usr");
            cookie.Values["ID"]   = student.Stu_ID.ToString();
            cookie.Values["pass"] = student.Stu_Password;
            cookie.Expires        = System.DateTime.Now.AddDays(1);//设置过期时间  1天
            Response.Cookies.Add(cookie);
            Response.Redirect("~/Home/Home.aspx");
        }
    }
Ejemplo n.º 2
0
    //验证登录
    //在cookie中添加user
    protected void Login_Click(object sender, EventArgs e)
    {
        StudentInfo student  = new StudentInfo();
        StudentInfo student2 = bllStudent.GetByName(Username.Text.Trim());

        if (student2 == null)
        {
            return;
        }
        student.Stu_ID       = student2.Stu_ID;
        student.Stu_Password = Password.Text.ToString().Trim();
        if (bllStudent.CheckLogin(student))
        {
            student2.Stu_LastLogin = DateTime.Now;
            bllStudent.Modify(student2);
            HttpCookie cookie = new HttpCookie("usr");
            cookie.Values["ID"]   = student.Stu_ID.ToString();
            cookie.Values["pass"] = Password.Text.ToString().Trim();
            cookie.Expires        = System.DateTime.Now.AddDays(1);//设置过期时间  1天
            Response.Cookies.Add(cookie);
            Response.Redirect("~/Home/Home.aspx");
        }
    }
Ejemplo n.º 3
0
    //验证用户名是否已经存在
    protected void RegisterValidate_ServerValidate(object source, ServerValidateEventArgs args)
    {
        StudentInfo student = bllStudent.GetByName(Name.Text.Trim());
        args.IsValid = (student==null);

    }