• cookie与session用法


    //记住的用户名
                    HttpCookie GetCookieUsersName = Request.Cookies["Login_UsersName"];
                    if (GetCookieUsersName != null && !string.IsNullOrEmpty(GetCookieUsersName.Value))
                    {
                        userName.Value = GetCookieUsersName.Value;
                    }


    //记住用户名
                                    HttpCookie CookieUsersName = new HttpCookie("Login_UsersName", userName.Value.Trim());
                                    Response.Cookies.Add(CookieUsersName);
    //十天免登录
                                    //Std.Page.StdUserControl.setSaveTime = 10;

    简单SESSION用法
    {
    session中存放一些值,比如
    Session["UserName"]="admin"
    Session["Pass"]="admin"

    然后在另外一个页面中,你可以使用它:
    If(Session["UserName"]="admin")
    ..........
    }
    #region 记录登录的Session
                                SessionUser sessionUser = new SessionUser();
                                sessionUser.UserId = user.UserId;
                                sessionUser.Account = user.Account;
                                sessionUser.UserName = user.RealName;
                                sessionUser.Gender = user.Gender;
                                sessionUser.Password = user.Password;
                                sessionUser.Code = user.Code;
                                sessionUser.Secretkey = user.Secretkey;
                                sessionUser.DepartmentId = user.DepartmentId;
                                sessionUser.LoginDate = DateTime.Now.ToString();
                                RequestSession.AddSessionUser(sessionUser);
                                #endregion

    //取出session
    SessionUser sessionUser = new SessionUser();
                sessionUser = RequestSession.GetSessionUser();

    Session.Abandon();//清除全部Session
    //清除某个Session
    Session["UserName"] = null;
    Session.Remove("UserName");

    vb.net版本

    '''清除全部

    Session.Abandon()

    Session.Clear()

    '''清除某个Session

    Session("UserInfo") = Nothing

    Session.Remove("UserInfo")

  • 相关阅读:
    Vue 学习笔记之 —— 组件(踩了个坑)
    Vue 学习笔记之 —— 表单输入绑定
    js cookie
    python中线程、进程和协程的区别
    设计模式
    Mysql从入门到精通整理
    如何处理缓存失效、缓存穿透、缓存并发等问题
    mysql 查询当天、本周,本月,上一个月的数据
    Mysql分表和分区的区别、分库分表介绍与区别(转)
    mysql数据库死锁的产生原因及解决办法
  • 原文地址:https://www.cnblogs.com/wybshyy/p/13783850.html
Copyright © 2020-2023  润新知