User session
A user session is like a place that Java web applications use to store data about each user. Each time a user access the application, a new session object is assigned to it. That means that each user has its own session. A session allows us to identify a user. It is a temporal storage where we (and Vaadin) can put data relevant to a user.
Note
Because sessions are temporal, we can configure their lifetime (or timeout) in web.xml
:
<web-app ...>
...
<session-config>
<session-timeout>20</session-timeout>
</session-config>
</web-app>
Note
Here, each session will last 20 minutes since the last time the user requested something to the server.
Vaadin automatically preserves the state of UI components (if @preserveOnRefresh
is present) by storing the required UI data into the user session. We don't have to worry about preserving UI components state. However we can still use the user session to store stuff not covered by any UI component. For...