首页  ·  知识 ·  云计算
单一登陆的例子
lovecherry  http://www.cnblogs.com/lovecherry/archive/2007/04/  综合  编辑:dezai  图片来源:网络
单一登陆就是一个帐号只能在一个地方登陆。后登陆的帐号会把前面登陆的帐号踢走。注意,只是介绍思路,代码很乱。 login.aspx.cs &nb

单一登陆就是一个帐号只能在一个地方登陆。后登陆的帐号会把前面登陆的帐号踢走。注意,只是介绍思路,代码很乱。

login.aspx.cs

    protected void Button1_Click(object sender, EventArgs e)
    {
        Session["name"] = TextBox1.Text;
        if (Cache["userlist"] == null)
        {
            System.Collections.Generic.Dictionary userlist = new System.Collections.Generic.Dictionary();
            userlist.Add(Session["name"].ToString(), Session.SessionID);
            Cache["userlist"] = userlist;
        }
        else
        {
            System.Collections.Generic.Dictionary userlist = Cache["userlist"] as System.Collections.Generic.Dictionary;
            userlist[Session["name"].ToString()] = Session.SessionID;
            Cache["userlist"] = userlist;
        }
        Response.Redirect("default.aspx");
    }
default.aspx.cs

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["name"] == null)
            Response.Write("");
        else if((Cache["userlist"] as System.Collections.Generic.Dictionary)[Session["name"].ToString()]!= Session.SessionID)
            Response.Write("");

    }

本文作者:lovecherry 来源:http://www.cnblogs.com/lovecherry/archive/2007/04/
CIO之家 www.ciozj.com 微信公众号:imciow
   
免责声明:本站转载此文章旨在分享信息,不代表对其内容的完全认同。文章来源已尽可能注明,若涉及版权问题,请及时与我们联系,我们将积极配合处理。同时,我们无法对文章内容的真实性、准确性及完整性进行完全保证,对于因文章内容而产生的任何后果,本账号不承担法律责任。转载仅出于传播目的,读者应自行对内容进行核实与判断。请谨慎参考文章信息,一切责任由读者自行承担。
延伸阅读