user2975535 user2975535 - 1 year ago 47
Scala Question

Session doesn't work after upgrade to Play Framework 2.5.4, Scala

After upgrading my project to Play Framework 2.5.4 from 2.4.8, I'm having issue while working with session. There are to methods in my controller to test the issue:

def test = Action { implicit request =>
Redirect(controllers.routes.Carts.test2()).withSession(new Session(Map("user" -> "customer")))

def test2 = Action { implicit request =>

method adds session and redirects to
method. When I open page with test method url after redirect I'm getting what I need in the browser:

Map(user -> customer)

But if I refresh page after that I'm getting:

Map(csrfToken ->

So, seems like session works for one request only and then overwrites with csrfToken. I have disabled all the filters. My class with filters looks like this:

class Filters @Inject() () extends HttpFilters {
val filters = Seq.empty

Can't understand what is wrong with my code. The same code was working fine before upgrade.

Answer Source

Check in ur application.conf if is true bring it to