在 JavaScript 中访问 Playframework 会话 [英] Access Playframework Session in JavaScript

查看:64
本文介绍了在 JavaScript 中访问 Playframework 会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Play 2.0.3/2.0.4.我在服务器端创建了一个 cookie(默认名称 = PLAY_SESSION)并尝试在 javascript 中访问它.

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.

我在 application.conf 文件中设置了 application.session.httpOnly=false.但是,在 javascript 中访问 c​​ookie 会返回 null.在 Chrome 中查找 cookie 说

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

可访问脚本:否(HttpOnly)

Accessible to script: No (HttpOnly)

不知道为什么 cookie 没有被标记为可被脚本访问

Not sure why the cookie is not marked accessible to script

推荐答案

application.conf 文件中要使用的正确键是 session.httpOnly.此密钥已在此提交中添加.

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

这篇关于在 JavaScript 中访问 Playframework 会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆