Esempio n. 1
0
        private void UserLogin()
        {
            string userName = Request["txtLoginId"];
            string userPwd  = Request["txtLoginPwd"];
            string msg      = string.Empty;

            Model.User userInfo = null;

            bool b = UserManager.CheckUserInfo(userName, userPwd, out msg, out userInfo);

            if (b)
            {
                Session["userInfo"] = userInfo;
                //判断用户是否选择了”自动登录“
                if (!string.IsNullOrEmpty(Request["cbAutoLogin"]))
                {
                    HttpCookie cookie1 = new HttpCookie("cp1", userName);
                    HttpCookie cookie2 = new HttpCookie("cp2", Common.WebCommon.GetMd5String(Common.WebCommon.GetMd5String(userPwd)));
                    cookie1.Expires = DateTime.Now.AddDays(7);
                    cookie2.Expires = DateTime.Now.AddDays(7);
                    Response.Cookies.Add(cookie1);
                    Response.Cookies.Add(cookie2);
                }

                //单击提交按钮,会将隐藏域的值提交过来。
                if (string.IsNullOrEmpty(Request["hiddenReturnUrl"]))
                {
                    Response.Redirect("/Default.aspx");
                }
                else
                {
                    Response.Redirect(Request["hiddenReturnUrl"]);
                }
            }
            else
            {
                Msg = msg;
            }
        }