In Java EE HttpSession, when I set the session timeout to negative (by using setMaxInactiveInterval), supposedly, I thought it should be retained even after the browser is closed. But according to this page Session Lost when closing the browser, it seems like it doesn’t.
How can this happen? Then I have to use a cookie to store the session id? Then how am I going to generate this session id by myself? I will lose the HttpSession’s advantage if I manage the session by myself.
I am using Tomcat in this case. How do you all settle this issue? Any simplest way in doing this?
Instead of using cookies you could use a flag in the database to check whether the person has logged out or not. So you don’t have to worry about the filters and the cookies
Make sure to toggle the flag once the user logs out.