如何验证会话?应该识别新用户和当前用户? [英] How to validate session?it should identify new user and current user?

查看:59
本文介绍了如何验证会话?应该识别新用户和当前用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有人知道吗?


Hi,

Can anyone know?


How to validate session?it should identify new user and current user?

推荐答案

登录后...
在您的页面加载事件中添加一个条件...就像这样...

after login...
put a condition in your pageload event...like this...

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["User"] == null)
            {
                Response.Redirect("login.aspx");
            }
        }
        if (Session["SessionId"] == null)
        {
            Response.Redirect("login.aspx");
        }
        Response.Buffer = true;
        Response.ExpiresAbsolute = DateTime.Now.AddDays(-1d);
        Response.Expires = -1500;
        Response.CacheControl = "no-cache";
    }


这篇关于如何验证会话?应该识别新用户和当前用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆