HttpSession has a getMaxInactiveInterval method that can tell you how many sessions will remain available to the user.
If you setMaxInactiveInterval to a negative number, it will never expire until it deletes cookies.
EDIT:. For your comment to another answer, where I cannot add a comment, if the user does not accept cookies, he will never have a session. Therefore, if he removes it, he will begin a new session.
source share