Access Playframework Session in JavaScript

2019-08-10 02:53发布

问题:

I am using Play 2.0.3 / 2.0.4. I create a cookie on the server side (default name = PLAY_SESSION) and am trying to access it in javascript.

I have set the application.session.httpOnly=false in application.conf file. However accessing the cookie in javascript return null. Looking up the cookie in Chrome says

Accessible to script: No (HttpOnly)

Not sure why the cookie is not marked accessible to script

回答1:

The correct key in application.conf file to use is session.httpOnly. This key was added in this commit.