zoukankan      html  css  js  c++  java
  • 单一登陆的例子

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

    login.aspx.cs

        protected void Button1_Click(object sender, EventArgs e)
        {
            Session[
    "name"= TextBox1.Text;
            
    if (Cache["userlist"== null)
            {
                System.Collections.Generic.Dictionary
    <string,string> userlist = new System.Collections.Generic.Dictionary<string,string>();
                userlist.Add(Session[
    "name"].ToString(), Session.SessionID);
                Cache[
    "userlist"= userlist;
            }
            
    else
            {
                System.Collections.Generic.Dictionary
    <stringstring> userlist = Cache["userlist"as System.Collections.Generic.Dictionary<stringstring>;
                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(
    "<script>alert('请登陆');location.href='login.aspx';</script>");
            
    else if((Cache["userlist"as System.Collections.Generic.Dictionary<stringstring>)[Session["name"].ToString()]!= Session.SessionID)
                Response.Write(
    "<script>alert('已经有相同帐号登陆');location.href='login.aspx';</script>");

        }
  • 相关阅读:
    字符集转换
    基础语法
    python print格式化输出。
    错误:SyntaxError: Missing parentheses in call to 'print'
    delphi 线程教学第一节:初识多线程
    delphi 7 信息对话框的按钮屏蔽键盘操作,只允许鼠标点击
    delphi 7 下安装 indy 10.5.8 教程
    delphi 实现vip126发邮件
    delphi 基础书籍推荐
    delphi 编码速度提升技能
  • 原文地址:https://www.cnblogs.com/lovecherry/p/724878.html
Copyright © 2011-2022 走看看