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

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