what is the default expiration time of a cookie

2019-02-16 03:48发布

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

2条回答
成全新的幸福
2楼-- · 2019-02-16 04:49

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

查看更多
SAY GOODBYE
3楼-- · 2019-02-16 04:51

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

enter image description here

查看更多
登录 后发表回答