zoukankan      html  css  js  c++  java
  • 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")

  • 相关阅读:
    【QTP小技巧】02_QTP中Complete Word 实现(转载)
    【QTP专题】04_对象及操作方法
    【QTP专题】03_Add-in Manager插件
    【QTP专题】02_时间同步点问题
    loadrunner 11问题汇总
    system idle process
    html div四边阴影效果
    通过CSS实现 文字渐变色 的两种方式
    UIgradients – 美丽的UI渐变色分享站 并可转成CSS代码
    display:inline-block带来的问题及解决办法
  • 原文地址:https://www.cnblogs.com/wybshyy/p/13783850.html
Copyright © 2011-2022 走看看