有没有用 GAE 管理会话 cookie 的简单方法?我只需要对用户等进行身份验证。
谢谢。
您可以使用用户 API对用户进行身份验证 - 使用 Google 帐户或 OpenID。如果您想要没有用户登录的会话,有许多库,例如gaesessions。
是的,这对我来说是使用 Python 2.7 最简单的方法。
import Cookie
value_session = "userid (encrypted);time of login"
name_cookie = "sessioncookie"
expires = 2629743 # 1 month in seconds
D = Cookie.SimpleCookie()
D["name_cookie"] = value_session
D["name_cookie"]["path"] = "/"
D["name_cookie"]["expires"] = expires
print(D)