For how long does a session :
HttpSession session = request.getSession();
last when I do not explicitly declare session.setMaxInactiveInterval(int i)
? Let us assume, the user doesn't delete the cookies from his browser.
As long as the declared value of session-timeout
in web.xml
states. If there is no value specified there, the container decides this setting.
HttpSession
has getMaxInactiveInterval
method which can tell you how much the session will stay available for the user.
If you setMaxInactiveInterval
to a negative number it'll never expire as long as he doesn't delete cookies.
EDIT : For your commentary on the other answer where I can't add a comment, if the user doesn't accept cookies, he'll never have a session. So if he deletes it, he'll start a new session.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With