Play Framework: Session's Gotchas
I've just switched our cookies to Play's Session. I was previously under the impression that "Session" is temporary, as in the stored value isn't persisted after the browser is closed.
After looking closely at it, Play's Session is implemented using a cookie, and we can simply set maxAge in order to make it behave like a persisted cookie.
Here are the 2 gotchas:
play.http.session.maxAgeis of the typeFiniteDuration. Therefore, in yourapplication.conf, you would have to set it to something likeplay.http.session.maxAge="31536000s", not just31536000.- You can use
addingToSessionandremovingFromSessionas the replacements forwithCookiesanddiscardCookies.- Please note that
withSessionisn't a replacement forwithCookiesbecause it replaces the whole Session. It doesn't add like howwithCookiesadds new cookies to the current set of cookies.
- Please note that