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 {
  Redirect(routes.Application.login).withNewSession.flashing(
    "success" -> "You've been logged out"
  )
}  

The withNewSession method destroys the old session.

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.