By Alvin Alexander. Last updated: June 6, 2016
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.