Why setMaxAge() and getMaxAge() methods are used in Cookies?

Answer Posted / abhijitbaji

setMaxAge(), this function sets the maximum age of the
cookie.
The value of the maximum age is the lifetime of the cookie
in seconds.
It is a decimal non-negative integer.
When the age is greater than seconds of maximum age, the
client SHOULD discard the cookie.
A value of zero means the cookie SHOULD be discarded
immediately.


getMaxAge(), this function can be used to retrieve the
maximum age of the cookie.

Is This Answer Correct ?    10 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of servlet wrapper classes?

886


Explain the architechure of a servlet?

829


What do you mean by mime type?

770


How to notify an object in session when session is invalidated or timed-out?

831


What is the workflow of a servlet?

894


why we should override only no-agrs init() method.

873


Why is servlet used?

896


What do you mean by filter in servlet?

734


What is Request Dispatcher?

1069


How can we achieve transport layer security for our web application?

783


Whats the advantages using servlets over using CGI?

806


What is the difference between Server and Container?

873


What is the process to implement doget and dopost methods?

731


If my browser does not support cookie, and my server sends a cookie instance what will happen?

832


What do you mean by annotations in servlet?

786