How Sessions Work
Now that you see that servlets and Java Server Pages can support sessions, you can take a step back and look at how the sessions work. When the servlet engine creates a session, it sends a session identifier (also referred to as a session key earlier in this chapter) back to the browser in the form of a cookie. Again, the cookie is just a piece of information that the browser sends back to the server whenever it asks the server for a page.
Usually, for a session, the cookie disappears when the Web browser is shut down.
A browser can, however, save cookies to disk, so that when the browser starts up again it still knows about the cookies it had when it was shut down. Because sessions are typically short-lived, and because shutting ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access