Why setMaxAge() and getMaxAge() methods are used in Cookies?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / tulasi vani
Cookies are created as
Cookie c=new Cookie(name,value);
c.setMaxAge(milliseconds);
int getMaxAge() returns the maximum age of the cookie.
If the value is set to zero it will be deleted
immediately.If the age is a -ve number it states that the
age of the cookie is confined to that particular request
only.
| Is This Answer Correct ? | 2 Yes | 6 No |
How are Sessions are more advantage than using of Cookies or URLReWriting?
Define declaration.
In which cases Destroy() is invoked?
what is servlet life cycle?
When a client request is sent to the servlet container, how does the container choose which servlet to invoke?
What is a java servlet?
can anybody send me j2ee softwares such as tomcat,weblogic server ,netbeans
how to use servlets with j2ee ?
can it possible to validate form field before execution of a servlet service method if yes how??
What is a web container and what is its responsibility?
What is the use of httpservletresponsewrapper?
How to get ip address in jsp login page and how to validate like 127.1.0.1 all should not be greater than 255