LongLivedCookie.java Subclass of Cookie that automatically sets the max age to one year.
package cwp;
import javax.servlet.http.*;
/** Cookie that persists 1 year. Default Cookie doesn't
* persist past current session.
*
* Taken from Core Web Programming Java 2 Edition
* from Prentice Hall and Sun Microsystems Press,
* .
* May be freely used or adapted.
*/
public class LongLivedCookie extends Cookie {
public static final int SECONDS_PER_YEAR = 60*60*24*365;
public LongLivedCookie(String name, String value) {
super(name, value);
setMaxAge(SECONDS_PER_YEAR);
}
}