• 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")

  • 相关阅读:
    Evensgn 的债务
    Passward
    拯救莫莉斯
    文艺平衡树
    Fliptile 翻格子游戏
    Making the Grade (bzoj1592)
    紧急疏散evacuate
    Password
    [NOIP2015]斗地主
    运输问题1
  • 原文地址:https://www.cnblogs.com/wybshyy/p/13783850.html
Copyright © 2020-2023  润新知