I was trying to locate some description or example how one properly logs out of a Vaadin application. In my application I want to provide a "logout" button or link that erases/clears the session so that one subsequently has to log in again. How does one do that?
// logout button
Button logoutButton = new Button("Logout", VaadinIcon.SIGN_OUT.create());
logoutButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY, ButtonVariant.LUMO_ERROR, ButtonVariant.LUMO_SMALL);
logoutButton.addClickListener(e -> {
VaadinSession.getCurrent().getSession().invalidate();
UI.getCurrent().getPage().reload();
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.