aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt between setMaxAge() and setMaxInactiveInterval() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt between setMaxAge() and setMaxInactiveInterval() method" Watch "Doubt between setMaxAge() and setMaxInactiveInterval() method" New topic
Author

Doubt between setMaxAge() and setMaxInactiveInterval() method

prashant k. gupta
Ranch Hand

Joined: May 15, 2008
Posts: 62
I have doubt on these two methods :- setMaxAge() for cookie and setMaxInactiveInterval() for session... what will happen if we set -1 for these method?

can someone please clarify.
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
A negative number for setMaxIncativeInterval causes the Session to never expire.
A negative number for setMaxAge causes the cookie to persist until browser shutdown.


JDBCSupport - An easy to use, light-weight JDBC framework -
Ankit Mishra
Ranch Hand

Joined: Jul 15, 2009
Posts: 40
when you will put -1 as a value that means for cookies you don't want that cookie to be removed even when session expires or when client leaves the browser. In case of session you don't want to invalidate it on the basis of time.

Correct me if i am wrong


Regards,
Ankit Mishra (SCJP 5.0 93%), (SCWCD 5.0 97%)
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
Ankit Mishra wrote:when you will put -1 as a value that means for cookies you don't want that cookie to be removed even when session expires or when client leaves the browser. In case of session you don't want to invalidate it on the basis of time.

Correct me if i am wrong


Not correct.
This is what the API states for setMaxAge()...

A negative value means that the cookie is not stored persistently and will be deleted when the Web browser exits. A zero value causes the cookie to be deleted.

Ankit Mishra
Ranch Hand

Joined: Jul 15, 2009
Posts: 40
got your point Sebastian thanks went through the api too ..
prashant k. gupta
Ranch Hand

Joined: May 15, 2008
Posts: 62
Ankit Mishra wrote:got your point Sebastian thanks went through the api too ..



Thanks Sebastian and Ankit for your quick response.
 
jQuery in Action, 2nd edition
 
subject: Doubt between setMaxAge() and setMaxInactiveInterval() method