Category Archives: Flash

How to use Cookies in Play framework


Browser Cookies in Play framework

Knoldus

Play framework is being used by every Scala developer now a days. In this post we’ll learn about using Cookies in Play framework.

Play has a stateless architecture so in order to keep the data across multiple HTTP request we can use Session & Flash. But both Session & Flash loose data as soon as browser is closed. So, to retain data even after closing the browser, we can use Cookies in Play framework. Cookies are not stored by the server, instead they are stored at the client side.

  • Data stored in cookies are available till they expire or they are cleaned by user.
  • We can set the expiration time of cookies.
  • They can be made secure, but only for sites working on HTTPS.
  • They can be used like a Scala collection.

Before start using Cookies in Play framework these two libraries have to imported.

Storing the data in Cookie :

For the…

View original post 134 more words

Advertisements