Session in Play Framework (scala)


(sowmya) #1

Hi,
I want to know more about Session management in Play Framework.Can anyone give me links to refer.

Thanks in advance


(Patrick Li) #2

This is the official documentation on Session in Play Framework. Essentially instead of storing things in memory on the server like JEE compliant containers do, Play stores data on the client side with a cookie, which is signed with a secret key. This lets your app to be stateless so you can horizontally scale out very easily, but you can only store Strings or String representations of your data in session.


(sowmya) #3

Thank you

i have seen that link, i wanted to know more about session


(sowmya) #4

Can i know how to store session in database


(Patrick Li) #5

Why do you want to store session in database?


(sowmya) #6

There are many servers and also we need to take care of load balancing.


(Patrick Li) #7

Play’s session is managed on the client side, not server side, so you do not need to persist session data in a database to share it across multiple servers. Play is stateless by default, so you can easily have multiple instances of the the same app with a load balancer such as Nginx in front without having to do anything.


(sowmya) #8

Ok Thank you ,
I will go through Nginx


(sowmya) #9

Nginx takes care of load balancing in web server, but i want to know about load balancing in application server.


(Patrick Li) #10

If you set up Nginx or Apache etc… as reverse proxy in front of the app servers, then Nginx will load balance for you.