什么是cookie的默认到期时间 [英] what is the default expiration time of a cookie

查看:724
本文介绍了什么是cookie的默认到期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在默认情况下会是怎样一个cookie的到期时间使用C#代码加入?



 的HttpCookie myCookie时=新的HttpCookie( myCookie时); 
myCookie.Value = txtCookie.Text;
//添加cookie。
Response.Cookies.Add(myCookie时);


解决方案

默认的Expires 对cookie的值不是一个静态的时间,但它会创建一个会话cookie 。直到用户关闭浏览器,这将保持活跃/清除其cookie。您可以覆盖此要求



从链接的页面:




设置过期属性MINVALUE使这是一个会话cookie,
这是它的默认值



By default what will be the expiration time of a cookie added using C# code?

    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. This will stay active until the user closes their browser/clears their cookies. 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

这篇关于什么是cookie的默认到期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆