简体   繁体   English

Cookie的默认到期时间是多少

[英]what is the default expiration time of a cookie

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);

The default Expires value for a cookie is not a static time, but it creates a Session cookie. Cookie的默认Expires值不是静态时间,但会创建一个Session cookie。 This will stay active until the user closes their browser/clears their cookies. 这将保持活动状态,直到用户关闭其浏览器/清除其cookie。 You can override this as required. 您可以根据需要覆盖它。

From the linked page: 从链接页面:

Setting the Expires property to MinValue makes this a session Cookie, which is its default value 将Expires属性设置为MinValue使其成为会话Cookie,这是其默认值

20 minutes. 20分钟。
In IIS, click on your website, and go to Session State. 在IIS中,单击您的网站,然后转到“会话状态”。 In the second box (Cookie Settings), you can change the time out(in minutes). 在第二个框中(“ Cookie设置”),您可以更改超时(以分钟为单位)。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM