Play Framework - How to logout and destroy the session

The following example from the Play Framework 'zentasks' application shows how to do a logout, and destroy the user's session at the same time:

 * Logout and clean the session.
def logout = Action {
    "success" -> "You've been logged out"

The withNewSession method destroys the old session.

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.