Online Java Compiler By
JavaTpoint.com
import java.net.HttpCookie; public class JavaHttpCookieGetMaxAgeExample3 { public static void main(String[] args) { HttpCookie cookie = new HttpCookie("Employee", "2"); //-1 represents that the given cookie exists until the browser is shut down. System.out.println("The maximum age of the cookie is given as: "+cookie.getMaxAge()); } }
Output