Java HttpCookie setMaxAge() MethodThe setMaxAge(long expiry)method of Java HttpCookie class is used to set the maximum age of the cookie within seconds. The result with a positive value indicates that the cookie will expire after the specified time in seconds. The result with a negative value indicates that the cookie is not stored persistently and will be deleted. SyntaxParameterThe above method consist of only one parameter:
ReturnN.A. Example 1Test it NowOutput: The maximum age of the cookie is given as: 5000 Example 2Test it NowOutput: The maximum age of the first cookie is given as: 3500 The maximum age of the second cookie is given as: 4500 Example 3Test it NowOutput: The maximum age of the cookie is given as: -1 Next TopicJava HttpCookie |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India