The Cookie class in Java servlets/JSP uses setMaxAge(int seconds) to set the cookie's maximum age in seconds. The parameter must be an integer, not a float. Negative values delete the cookie, zero deletes it immediately, and positive values set the expiration time.