Tim Joseph
Tim Joseph

Reputation: 847

Difference between Play Framework Session and PHP Session

if I understand correctly, the Play Framework uses cookies to store the whole session, while PHP just stores a Session-ID in a cookie and saves the real session itself on the server-side.

The Play Framework promotes good horizontal scalability with its approach. But I do not see the advantage, if I use any other framework and save my session into a database, for example with Symfony and Redis.

So how is the Play Framework better (for some use cases)?

Upvotes: 1

Views: 266

Answers (1)

jacks
jacks

Reputation: 4753

The initial idea behind Play's architecture is that the designers wanted it to be stateless ie. no data being maintained between requests on the server-side - this is why it does not follow the servlet spec. This opens up flexibility with things like scalability as you have mentioned - this is in itself a big advantage if your application is large enough that it needs to scale across more than a single machine - managing server-side session data across a cluster is a pain.

But of course, anything other than a trivial application, Will have a need to maintain some session data and as you have mentioned yourself you would usually do this with a cache or DB. The cookie session Play uses is restricted to about 4Kb so is only intended for a relatively small amount of data.

The benefits of a stateless architecture are manyfold and are what Play's architecture is designed to exploit.

A bit dated but the relevancy still applies in this article.

Upvotes: 1

Related Questions