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

推荐订阅源

Recent Announcements
Recent Announcements
J
Java Code Geeks
雷峰网
雷峰网
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
腾讯CDC
博客园 - 司徒正美
B
Blog RSS Feed
博客园 - 三生石上(FineUI控件)
I
InfoQ
N
Netflix TechBlog - Medium
L
LangChain Blog
博客园_首页
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Tailwind CSS Blog
MyScale Blog
MyScale Blog
美团技术团队
The Cloudflare Blog
爱范儿
爱范儿
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
H
Help Net Security
Martin Fowler
Martin Fowler
V
Visual Studio Blog

博客园 - 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后设置过期。

搞的有点晕