• cookie


    代码如下:

           //设置httpcookie    
            HttpCookie cscok = new HttpCookie("ckall");
            cscok.Values.Add("uname", "1111111");                //uname为变量名,1111111为变量的值
            cscok.Values.Add("upwd", "2222");                        //同上解释
            cscok.Expires = DateTime.MaxValue;                      //设置httpcookie集合的过期时间
            Response.AppendCookie(cscok);                            //写入httpcookie 类中

            //获取httpcookie
            HttpCookie hqcok = Request.Cookies["ckall"];         //获取httpcookie类集合
            if (hqcok != null)                                                       //判断是否为空
            {
                Response.Write(hqcok.Values["uname"].ToString());
                Response.Write(hqcok.Values["upwd"].ToString());

                //下面是清除httpcookie类集合

                hqcok.Expires = DateTime.Now.AddMinutes(-1);     //设置httpcookie的过期时间为-1
                Response.AppendCookie(hqcok);                            //将设置的过期值写入httpcookie从而清除类值
            }
            else
            {
                Response.Write("没有设置cookies值");
            }

  • 相关阅读:
    python爬虫之requests库
    python爬虫之urllib库
    fiddler配置及使用教程
    react中受控组件相关的warning
    Sublime Text 自动生成文件头部注释(版权信息):FileHeader 插件的使用
    手动安装sublime插件babel-sublime
    自定义组件 点击空白处隐藏
    pagination分页(支持首页,末页,跳转)
    vue打包以后,除了首页意外,其余页面是空白
    pm2踩过的坑
  • 原文地址:https://www.cnblogs.com/rhythmK/p/1517524.html
Copyright © 2020-2023  润新知