• asp.net做的网站账号登陆后注销不管用了


    最近做了个项目用到了数据库登录,A登陆后把登录状态保,个人信息存在Session里,但是奇怪的是,只要有一个用户登录后在其他电脑上打开上述页面,则也显示A登录状态,注销也不管用了。以前还号的。求大神啊。 以下是BasePage的代码,其他需要验证登录的页面继承该类

    public class BasePage : System.Web.UI.Page
        {
            //protected User_Info Uinfo = new User_Info();
    
            //登录的判断
            public static User_Info currUser = null;
            protected void Page_PreInit(object sender, System.EventArgs e)
            {
                if (currUser == null && Session["UserInfo"] != null)
                {
                    currUser = (User_Info)Session["UserInfo"];
                }
                else
                {
                    if (currUser == null)
                    {
                        Response.Cookies.Add(new HttpCookie("_URL_REFERRER", Request.Url.ToString()));
                        System.Web.HttpContext.Current.Response.Redirect("../Admin/Login.aspx");
                        Response.End();
                    }
                    else
                        Session["UserInfo"] = currUser;
                }
            }
        }

     以下是登录页面的登录方法的代码

    private void btnLogin_Click(object sender, System.Web.UI.ImageClickEventArgs e)
            {            
                string userName = Pwl.Common.PageValidate.InputText(txtUsername.Value.Trim(), 30);
                string Password = Pwl.Common.PageValidate.InputText(txtPass.Value.Trim(), 30);
                //Password = Pwl.DBUtility.DESEncrypt.Encrypt(Password);
                //Password = "1";
                Pwl.Model.User_Info userInfo = Pwl.DAL.User_Info.Instance.UserAuthorize(userName, Password);
                if (userInfo != null)
                {
                    Session["UserInfo"] = userInfo;
                    if (Pwl.DAL.User_Authority.Instance.IsAdmin((int)Pwl.Common.Pwl_Right.超级管理员, userName))
                    {
                        Response.Redirect("Index.aspx");
                    }
                    if (Request.Cookies["_URL_REFERRER"] != null)
                    {
                        String strUrlReferrer = Request.Cookies["_URL_REFERRER"].Value;
                        Response.Cookies["_URL_REFERRER"].Expires = DateTime.Now.AddDays(-2);
                        //清空记录路径Cookie
                        Response.Redirect(strUrlReferrer);
                    }
                    else
                    {
                        Response.Redirect("../Portal/UserMessage.aspx");
                    }
                }
                this.lblMsg.Text = "用户名或密码错误!";
    
            }

    一下是
    注销方法的代码

    //注销
            protected void lbtLoginOut_Click(object sender, EventArgs e)
            {
                Session.Remove("UserInfo"); 
                Pwl.Common.BasePage.currUser = null;
                Response.Redirect("../Default.aspx");
            }
    
    等啊
  • 相关阅读:
    Spring Boot JDBC 使用教程
    Spring Boot FreeMarker 使用教程
    椭圆曲线ECC ECDH原理&& javacard实现
    java中的强制类型转换:int和byte
    JUnit学习
    java异常处理
    Maven使用
    哈希表问题
    计数排序
    链表Linked List
  • 原文地址:https://www.cnblogs.com/zxyily38/p/3292349.html
Copyright © 2020-2023  润新知