Home Segments Top Top Previous Next

1061: Mainline

Ordinary cookies stay on the client there until they become too old. It is up to you to decide what too old means. If you do nothing, a cookie is too old as soon as the client browser shuts down. Otherwise, you can set the lifetime of a cookie, specifying it in seconds. For example, the following destroys a cookie immediately:

cookie.setMaxAge(0); 

The following causes a cookie to persist for 1 year:

cookie.setMaxAge(60 * 60 * 24 * 365);