Skip to content

Instantly share code, notes, and snippets.

@JosephMoniz
Created May 3, 2015 04:25
Show Gist options
  • Save JosephMoniz/7782a9a0ee4467080ceb to your computer and use it in GitHub Desktop.
Save JosephMoniz/7782a9a0ee4467080ceb to your computer and use it in GitHub Desktop.
An example of how to use sessions
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