C# cookie 的默认过期时间是多少
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19002254/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
what is the default expiration time of a cookie
提问by Sudha
By default what will be the expiration time of a cookie added using C# code?
默认情况下,使用 C# 代码添加的 cookie 的到期时间是多少?
HttpCookie myCookie= new HttpCookie("myCookie");
myCookie.Value = txtCookie.Text;
// Add the cookie.
Response.Cookies.Add(myCookie);
采纳答案by CodingIntrigue
The default Expiresvalue for a cookie is not a static time, but it creates a Session cookie. This will stay active until the user closes their browser/clears their cookies. You can override this as required.
cookie的默认Expires值不是静态时间,但它会创建一个会话 cookie。这将保持活动状态,直到用户关闭浏览器/清除 cookie。您可以根据需要覆盖它。
From the linked page:
从链接页面:
Setting the Expires property to MinValue makes this a session Cookie, which is its default value
将 Expires 属性设置为 MinValue 使其成为会话 Cookie,这是其默认值
回答by Cameron Castillo
20 minutes.
In IIS, click on your website, and go to Session State. In the second box (Cookie Settings), you can change the time out(in minutes).
20分钟。
在 IIS 中,单击您的网站,然后转到会话状态。在第二个框(Cookie 设置)中,您可以更改超时时间(以分钟为单位)。