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
What if we pass negative value in load-on-startup?
What is servlet in simple terms?
What is the purpose of requestdispatcher interface?
Why are servlets used?
Tell us something about servletconfig interface.
Is tomcat a servlet container?
What is httpservlet and how it is different from genericservlet?
What is difference between ServletResponse sendRedirect() and RequestDispatcher forward() method?
What is setattribute in servlet?
What are different Authentication options available in Servlets.
what is the different between a servlet and a cgi? Why do you go for servlet rather than cgi?
Why do we need servlet filter?
What is SingleThreadModel interface?
Write all the phases defined in servlet life cycle?
What are important features of Servlet 3?