开发者

Wicket session not persisted in GAE

开发者 https://www.devze.com 2023-02-17 21:46 出处:网络
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 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! Chr开发者_运维问答is


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.


I spent about 2 days devling down the rabbit hole of sessions and cookies and I finally realised my issue was this:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消