Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play framework: how to monitor number of active sessions with standard session API?

In Play framework there is an API to create a session, put some data to the session and discard the session. But I would also like to have some insight into things like how many active sessions are currently in my installation, how many data in volume is bound to them, etc. Are there any means to deal with this?

like image 960
Alexander Arendar Avatar asked Mar 21 '15 09:03

Alexander Arendar


1 Answers

Play is by stateless by nature, thus no session exists on the server to be tracked or monitored. When you use session API you just create a cookie that will be sent with every request / response from/to the browser.

This cookie doesn't have a timeout or expiration date, hence it will persist as long as the browser is open. However you can implement your own session timeout mechanism by setting a last access time on the session cookie and compare it to the desired timeout on every request.

like image 76
faissalb Avatar answered Nov 15 '22 03:11

faissalb