This is a pretty basic question. I'm learning from a textbook about JSF web apps, and using a @SessionScoped Bean to manage the session. The book mentioned that if you close the browser, the session ends, and this was easy to verify with testing. But I am not sure how the web app is informed that the browser has been closed and re-opened. I couldn't find any cookies stores locally. So how does the web app get this info?
Thanks!
It's a Session Cookie that does the magic.
In fact when you arrive to any web page of your application, you start an http session. Then your browser stores a sessionId used as identifier for following requests.
So when the browser is closed, there is no way that your application knows about that.
The only way to finish the session from the server side is by setting up a timeout in the web.xml. When there is no request form the browser before the timeout is triggered, then all the methods in the managed beans of this session annotated with @PreDestroy will be called and then everything will be cleanup in the server side.