惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
罗磊的独立博客
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Last Week in AI
Last Week in AI
美团技术团队
Google Online Security Blog
Google Online Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
月光博客
月光博客
L
LINUX DO - 最新话题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
W
WeLiveSecurity
H
Heimdal Security Blog
Vercel News
Vercel News
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
A
About on SuperTechFans
C
Check Point Blog
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
AI
AI
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
博客园_首页
The Last Watchdog
The Last Watchdog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
I
Intezer
K
Kaspersky official blog
M
MIT News - Artificial intelligence
J
Java Code Geeks
G
GRAHAM CLULEY
P
Palo Alto Networks Blog

博客园 - sh37

Newtonsoft中的几个妙用 Mvc中ViewData与TempData的区别 Silverlight中利用ListBox特性实现单选按钮组RadioButtonList和复选按钮组CheckBoxList的功能 SilverLight中Page也可使用泛型基类 C# 利用net 命令获取域用户列表 - sh37 利用MessageQueue收发消息 - sh37 - 博客园 C# xmlhttp - sh37 - 博客园 使用ASP获得AD帐号 “域\用户名” - sh37 - 博客园 使用ASP.NET获得AD帐号 - sh37 - 博客园 根據xml文檔數據 給DataTable增加行 JS获取剪贴板内容的代码 - sh37 - 博客园 分页时使当前页码变色 C#生成缩略图 自動生成帶文字的圖片 常用pl/sql vb.net後台抓取網頁內容 ServerVariables集合内容列表 如何动态创建一个按纽 并给这个按纽绑上一个Onclick事件 17种常用正则表达式
cookie操作 - sh37 - 博客园
sh37 · 2007-09-27 · via 博客园 - sh37

今天有空就把操作cookie的写了,虽然很简单,不过免得到时候忘记了。
        下面是写cookie
 HttpCookie cookie = new HttpCookie("Info");//定义cookie对象以及名为Info的项
 DateTime dt = DateTime.Now;//定义时间对象
 TimeSpan ts=new TimeSpan(1,0,0,0);//cookie有效作用时间,具体查msdn
 cookie.Expires = dt.Add(ts);//添加作用时间
 cookie.Values.Add("user","cxbkkk");//增加属性
 cookie.Values.Add("userid","1203");
 Response.AppendCookie(cookie);//确定写入cookie中        读取cookie
  if(Request.Cookies["Info"]!=null)
  {
      string temp=Convert.ToString(Request.Cookies["Info"].Values["user"])+"  "+Convert.ToString(Request.Cookies["Info"].Values["userid"]);
     //读全部就用Request.Cookies["Info"].Value)
     if(temp=="")
      {
          Response.Write("空");
      }
      else
         Response.Write(temp);
 }
 else
 {
     Response.Write("error");
 }       // 改cookie
 Response.Cookies["Info"]["user"] = "2";
 Response.Cookies["Info"].Expires = DateTime.Now.AddDays(1);        //删除cookie下的属性
 HttpCookie acookie=Request.Cookies["Info"];
 acookie.Values.Remove("userid");
 acookie.Expires = DateTime.Now.AddDays(1);
 Response.Cookies.Add(acookie);        //删除所有cookie,就是设置过期时间为现在就行了
 int limit=Request.Cookies.Count - 1;
 for(int i=0;i<limit;i++)
 {
     acookie = Request.Cookies(i)
     acookie.Expires = DateTime.Now.AddDays(-1)
     Response.Cookies.Add(acookie)
 }  

posted on 2007-09-27 11:02  sh37  阅读(196)  评论()    收藏  举报