You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

HandlingLogout.asciidoc 1.2KB

12345678910111213141516171819202122232425262728293031323334
  1. ---
  2. title: Handling Logout
  3. order: 21
  4. layout: page
  5. ---
  6. [[handling-logout]]
  7. = Handling logout
  8. What should happen the user wants to log out from a Vaadin application
  9. depends on how the user is stored when the user logged in.
  10. If the user information is stored in the `VaadinSession`, that session
  11. should be closed using its `close()` method. If the information on the
  12. other hand is stored in the `HttpSession` or `PortletSession`, then that
  13. session should be invalidated using the `invalidate()` method in Vaadin's
  14. `WrappedSession` that represents either underlying session type.
  15. Aside from removing the user's information, the user should also be
  16. redirected to a logout page to avoid keeping the UI open in the browser
  17. after all server-side information about is has been removed.
  18. [source,java]
  19. ....
  20. private void logout() {
  21. // Close the VaadinServiceSession
  22. getUI().getSession().close();
  23. // Invalidate underlying session instead if login info is stored there
  24. // VaadinService.getCurrentRequest().getWrappedSession().invalidate();
  25. // Redirect to avoid keeping the removed UI open in the browser
  26. getUI().getPage().setLocation(getLogoutPageLocation());
  27. }
  28. ....