GAE 中未保留 Wicket 会话
我有一个非常基本的 Wicket 应用程序,我正在尝试将其部署到 GAE。按照步骤 此处 并在创建时绑定会话对象。
我无法保存会话中的任何状态。我的会话类扩展了 AuthenticatedWebSession。登录页面通过 AuthenticatedWebSession.authenticate() 进行身份验证,该方法始终返回 true 并在成员变量中设置用户名。但后续页面会在会话中看到空用户名,并且 AuthenticatedWebSession.isSignedIn() 返回 false。
我似乎确实在维护一个会话,因为每个页面都会看到相同的 Session.getId() 值。
有什么想法吗?
蒂亚! 克里斯
I have a very basic Wicket app that I'm trying to deploy to GAE. I have the basics working, after following the steps here and also binding the session object upon creation.
I'm having trouble saving any state in a session. My session class extends AuthenticatedWebSession. The login pages authenticates via AuthenticatedWebSession.authenticate(), which always returns true and sets the username in a member variable. But subsequent pages see a null username in the session and AuthenticatedWebSession.isSignedIn() returns false.
I do seem to be maintaining a session, as every page will see the same value for Session.getId().
Any ideas?
TIA!
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的问题在 Wicket 邮件列表上得到了回答 - 答案是我需要在身份验证后(或在对会话成员进行任何其他更改后)调用 Session.dirty() 以确保它被保存。显然,在我的开发环境中,会话总是被保存,但 GAE 更加优化,因此只保存脏会话。
My question was answered on the Wicket mailing list - the answer is that I needed to call Session.dirty() after authenticating (or after any other change to the session members) to ensure it would be saved. Apparently in my development environment, sessions were always saved but GAE is more optimized and thus only saving dirty sessions.
我花了大约 2 天的时间研究会话和 cookie 的兔子洞,我终于意识到我的问题是这样的:
每次实例启动时,它都会生成一个新密钥,现在用户会话丢失了。
您需要将密钥设置为静态
希望这是您的问题
I spent about 2 days devling down the rabbit hole of sessions and cookies and I finally realised my issue was this:
Every time an instance boots up it generates a new key and now the users session is lost.
You need to make your key static
Hopefully this is your issue to