session = get_current_session()
a1 = session.has_key('account.logged') # is true
session2 = Session(sid=session.sid)
a2 = session2.has_key('account.logged') # is false为什么a2不等于a1?
解决方案:必须将其保存到数据存储:How to get current session with only the SID?
发布于 2010-11-10 03:01:22
问得好。按会话ID (SID)检索会话要求将会话存储在服务器上(在memcache或数据存储区中)。默认情况下,gae-sessions仅将会话存储在安全的客户端cookie中。这比将其存储到数据存储甚至是memcache (参见this article底部的性能比较部分)要快得多。
如果希望通过SID检索会话,则必须强制将会话存储在服务器上。您可以通过关闭仅cookie会话(仅当您需要经常通过SID检索时才推荐)或通过强制在服务器端存储特定会话(通过传递persist_even_if_using_cookie=True to save())来完成此操作。更多细节here。
https://stackoverflow.com/questions/4137099
复制相似问题