Javatpoint Logo
Javatpoint Logo

Java HttpCookie getMaxAge() Method

The getMaxAge() method of Java HttpCookie class is used to return the maximum age of the cookie within the seconds. By default, -1 represents that the given cookie exists until the browser is shut down.

Syntax

Parameter

N.A.

Return

The above method is used to return an integer which specifies the maximum age of the cookie within seconds.

Example 1

Test it Now

Output:

The maximum age of the cookie is given as: 1700

Example 2

Test it Now

Output:

The maximum age of the first cookie is given as: 2000
The maximum age of the second cookie is given as: 1000

Example 3

Test it Now

Output:

The maximum age of the cookie is given as: -1 
Next TopicgetName() Method





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA