简体   繁体   English

Wicket会议未在GAE中持续存在

[英]Wicket session not persisted in GAE

I have a very basic Wicket app that I'm trying to deploy to GAE. 我有一个非常基本的Wicket应用程序,我正在尝试部署到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. 我的会话类扩展了AuthenticatedWebSession。 The login pages authenticates via AuthenticatedWebSession.authenticate(), which always returns true and sets the username in a member variable. 登录页面通过AuthenticatedWebSession.authenticate()进行身份验证,该身份验证始终返回true并在成员变量中设置用户名。 But subsequent pages see a null username in the session and AuthenticatedWebSession.isSignedIn() returns false. 但后续页面在会话中看到空用户名,AuthenticatedWebSession.isSignedIn()返回false。

I do seem to be maintaining a session, as every page will see the same value for Session.getId(). 我似乎维护一个会话,因为每个页面都会看到Session.getId()的相同值。

Any ideas? 有任何想法吗?

TIA! TIA! Chris 克里斯

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. 我在Wicket邮件列表上回答了我的问题 - 答案是我需要在验证后(或在对会话成员进行任何其他更改之后)调用Session.dirty()以确保它被保存。 Apparently in my development environment, sessions were always saved but GAE is more optimized and thus only saving dirty sessions. 显然在我的开发环境中,会话总是被保存,但GAE更加优化,因此只保存脏会话。

I spent about 2 days devling down the rabbit hole of sessions and cookies and I finally realised my issue was this: 我花了大约2天的时间来讨论会话和饼干的漏洞,我终于意识到我的问题是:

app.secret_key = os.urandom(50)

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 你需要让你的密钥保持静态

app.secret_key = "really-complex-key-that-is-static-and-never-changes"

Hopefully this is your issue to 希望这是你的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM