Validity period in cookies in the Java web
(1) Java Web Background Add cookie
Cookie Emailcook = new Cookie (name2, "Whuang"); Emailcook.setpath ("/"); Response.addcookie (Emailcook);
(2) does not explicitly set the validity period, the validity period is the session, that is, after closing the browser will expire
(3) Set validity period:
Emailcook.setmaxage (10000000); Response.addcookie (Emailcook);
The unit of Setmaxage is: seconds
public void Setmaxage (int expiry)
Sets the maximum age of the cookies in seconds.
A positive value indicates that the cookie would expire after that many seconds has passed. Note that the value was the maximum age when the cookie would expire, not the cookie's current age.
A negative value means that the cookie was not stored persistently and would be deleted when the Web browser exits. A zero value causes the cookie to be deleted.
-
This article is from the "Whuang" blog, make sure to keep this source http://huangkunlun520.blog.51cto.com/2562772/1701945
The validity period of a Java Web cookie