Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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

Answers were Sorted based on User's Feedback



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

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

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

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

Post New Answer

More Servlets Interview Questions

How do you get the ip address of the client in servlet?

0 Answers  


How do you run a servlet?

0 Answers  


How to rectify errors in java servlet while compilation?

0 Answers  


can u give some realtime example in ploymorphism? and inheritance?

11 Answers   SolutionNET,


Why HttpServlet class is declared abstract?

0 Answers  






what are the different services provided by the web server?

2 Answers  


Can we use javascript in Servlets?

2 Answers   Wipro,


give the syntax of doGet() and doPost()?

2 Answers  


Can you call a jsp from the servlet?

0 Answers  


where the generated jsp source file are stored?

7 Answers   HCL,


Why is servlet used?

0 Answers  


What type of protocols are used in HttpServlet?

3 Answers  






Categories