zoukankan      html  css  js  c++  java
  • C# Cookie 使用

    一.Cookie

    public static void GetDB(string ID, string Name)
            {
                HttpCookie DBName = new HttpCookie("DB", ID);
                HttpCookie DB = new HttpCookie("DBName", Name);
                //设置过期时间
                DateTime dt = DateTime.Now;
                TimeSpan ts = new TimeSpan(0, 24, 0, 0, 0);//过期时间为10分钟
                DBName.Expires = dt.Add(ts);
                DB.Expires = dt.Add(ts);
                //ToKen.setMaxAge(60 * 10); //Cookie保存时间
                HttpContext.Current.Response.AppendCookie(DBName);
                HttpContext.Current.Response.AppendCookie(DB);
    
                HttpContext.Current.Request.Cookies["DB"].Value = ID;
                HttpContext.Current.Request.Cookies["DBName"].Value = Name;
            }

    三.关于过期时间TimeSpan

    TimeSpan ts0 = new TimeSpan(30);  //将时间间隔ts0初始化为30刻度数
    TimeSpan ts1 = new TimeSpan(1, 30, 30);  //将时间间隔ts1初始化为1小时30分30秒
    TimeSpan ts2 = new TimeSpan(2,12,30,30);  //将时间间隔ts2初始化为2天12小时30分30秒
    TimeSpan ts3 = new TimeSpan(7, 12, 30, 30,30);  //将时间间隔ts3初始化为7天12小时30分30秒30毫秒
  • 相关阅读:
    Assimp对FBX文件中geometric transformations的处理
    VSM
    WSL安装
    [p1880][NOI1995]石子合并
    【日常】集训总结
    【模板】背包
    【济南集训】20191006解题报告
    [P1516]青蛙的约会
    【模板】ST表
    【济南集训】20191001解题报告
  • 原文地址:https://www.cnblogs.com/ZxtIsCnblogs/p/9634433.html
Copyright © 2011-2022 走看看