Using sessions with MPR

The state of the in an MPR project is managed by the com.vaadin.flow.server.VaadinSession class, but the methods from the legacy com.vaadin.server.VaadinSession class can also be used, since both wrap the same javax.servlet.http.HttpSession.

Invalidating a session

To invalidate a session (and possibly start a new one), you can invalidate the session managed by Flow and reload the page.

For example:

Button close = new Button("Close session", event -> {
    VaadinSession.getCurrent().getSession().invalidate();
    UI.getCurrent().getPage().reload();
});