Created
May 3, 2015 04:25
-
-
Save JosephMoniz/7782a9a0ee4467080ceb to your computer and use it in GitHub Desktop.
An example of how to use sessions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final case class SessionVisitsController() extends Controller { | |
def action(implicit request: HttpRequest) = { | |
val visits = request.session.get("visits").getOrElse("0").toLong | |
Ok(s"This is so cool, you've viewed it $visits times!") | |
.withSession(request.session.set("visits", (visits + 1).toString)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment