简体   繁体   English

如何在Google App Engine上使用Session

[英]How to use Session on Google app engine

I do not know how to use Session on Google app engine. 我不知道如何在Google App Engine上使用Session。 Please tell me. 请告诉我。 Thanks. 谢谢。

Are you talking about request.getSession() in the Java Servlet API? 您是否在谈论Java Servlet API中的request.getSession()? You have to enable sessions before that will work. 您必须先启用会话,然后才能起作用。 See this question for more info on using HttpSession. 这个问题有关使用HttpSession的更多信息。 By the way, you should probably tag your questions with the App Engine variant you're using (java or python). 顺便说一句,您可能应该使用正在使用的App Engine变体(java或python)标记问题。

App Engine includes an implementation of sessions, using the servlet session interface. App Engine包括使用Servlet会话界面的会话实现。 The implementation stores session data in the App Engine datastore for persistence, and also uses memcache for speed. 该实现将会话数据存储在App Engine数据存储区中以实现持久性,并且还使用内存缓存来提高速度。 As with most other servlet containers, the session attributes that are set with session.setAttribute() during the request are persisted at the end of the request. 与大多数其他Servlet容器一样,在请求过程中使用session.setAttribute()设置的会话属性将在请求结束时保留。

This feature is off by default. 默认情况下,此功能是关闭的。 To turn it on, add the following to appengine-web.xml: 要启用它,请将以下内容添加到appengine-web.xml中:

<sessions-enabled>true</sessions-enabled>

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

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