Cookies are deleted when I close the browser?

cookie默认的生命周期,是跟着session走的。session结束了,cookie也就被自动清除了。不过可以设置cookie的过期时间来避免自动清除

Cookies are deleted when I close the browser?

The default cookie lifetime is “session”. You should set a maxAge:

this.cookies.set(Auth.STORAGE_KEY, token,
                 { path: '/', maxAge: 31536000 });

It’s in seconds.

365*24*3600=31536000一年的秒数

what is the default expiration time of a cookie

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

原文地址:https://www.cnblogs.com/chucklu/p/14848599.html