I am using Play Framework 2.2.0 with Scala. I want to expire the session after a fix time, so i put this code in conf/application.conf
application.session.maxAge=1h
but it is not working. Is there any way to set a maximum age for session in application.conf or by overriding any method from controller.If i want to expire session after 50 seconds would i have to code like this
application.session.maxAge=50sec
Thanks for replies
In Play Framework, you can't set the timeout yourself. As the documentation for the Scala version of the Play Framework states:
There is no technical timeout for the Session. It expires when the user closes the web browser. If you need a functional timeout for a specific application, just store a timestamp into the user Session and use it however your application needs (e.g. for a maximum session duration, maxmimum inactivity duration, etc.).
So you will have to simply write code for each Action
that checks how much time has elapsed between the current time and the creation of the session. I would suggest using a Filter.