I’m developing a Vaadin Flow application with Spring Boot and Spring Security and I’m facing an issue with user sessions.
I’m using SecurityContextHolder to retrieve the currently logged-in user.
I’m also using VaadinSession to try and maintain the session state.
However, when I refresh the page, the user gets logged out.
I was expecting the session to persist across page refreshes. Could someone guide me on how to properly handle user sessions in Vaadin to keep users logged in after a page refresh?
Did you check that the JSESSION cookie is the same after a refresh? If yes: the http session did not terminate and it’s more like a problem in your code instead of the Vaadin(Http)Session.
If you use VaadinWebSecurity, it configures the SecurityContextHolder to use VaadinSession, not HttpSession. This means that VaadinSession deseriallzation needs to be performed before SpringSecurity in your filter chain.