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

推荐订阅源

博客园 - 三生石上(FineUI控件)
博客园 - Franky
GbyAI
GbyAI
B
Blog
WordPress大学
WordPress大学
D
Docker
小众软件
小众软件
月光博客
月光博客
博客园 - 【当耐特】
T
The Blog of Author Tim Ferriss
IT之家
IT之家
腾讯CDC
Engineering at Meta
Engineering at Meta
Vercel News
Vercel News
H
Help Net Security
M
MIT News - Artificial intelligence
L
LangChain Blog
云风的 BLOG
云风的 BLOG
S
SegmentFault 最新的问题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
美团技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
V2EX
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

博客园 - Agent

更改VS.NET 默认SCM Provider的方法 关于VS.NET的SCM Plug-in Lippman的宣传 Important Issue About DataReader and DataGrid's Paging 上海照的 可为空的基础类型 Bad Smell Choice 做了一个小型的Dump以便于调试使用 - Agent - 博客园 It's Great VS2005 VS2005 My Assembler 有关JIT 凌晨三点不想睡 不学编程 别搞计算机了 天又要亮了 该死的宏 Uncle bob's View of dynamic and static languages
cookie的过期时间-- 郁闷又恼火 - Agent - 博客园
Agent · 2004-07-28 · via 博客园 - Agent

由客户端取得的cookie之中Expires属性为默认值0001-1-1 0:00:00!因此不要指望

                HttpCookie cookie = Request.Cookies["A"];
        
                
if (cookie == null)
                
{
                    cookie 
= new HttpCookie("A""0");
                    cookie.Expires 
= DateTime.Now.AddDays(1);
                    cookie.Value 
= 45.ToString();
                    Response.AppendCookie(cookie);
                }

                
else
                
{
                    cookie.Value 
= (1 + int.Parse(cookie.Value)).ToString();
                }

这样的代码会把修改后的cookie放回到客户端, 由于过期时间被重置为DefualtValue,  这个cookie将变为一个Session cookie。如果需要保存Cookie,  必须在每一次获取Cookie后设置过期。

搞的有点晕