Tag: gae模块

如何在Google App Engine Java应用程序之间共享模块之间的会话?

当我通过模块A中的HttpSession在会话中存储某些内容时: HttpSession session = req.getSession(true); session.setAttribute(“username”, “Eng.Fouad”); 然后我尝试从模块B中检索此信息(在同一浏览器会话期间): HttpSession session = req.getSession(true); String username = session.getAttribute(“username”); // null! 我将null作为值,这意味着不同的会话。 如何在GAE中跨多个模块共享会话? 旧答案,我认为它不能很好地工作: 我一直试图解决这个问题好几个星期。 事实certificate,模块不共享会话,因为不同子域的cookie是不同的(module1.apphost.com cookies!= module2.apphost.com cookies)。 要解决此问题,只需在每个模块的web.xml中设置cookie域: org.mortbay.jetty.servlet.SessionDomain .apphost.com org.mortbay.jetty.servlet.SessionPath / org.mortbay.jetty.servlet.SessionURL none … 额外: 以下是可以与Jetty cookie一起使用的所有init参数的列表: 编辑:开发环境的解决方法: 使每个模块的端口固定(使用JVM arg -Dcom.google.appengine.devappserver_module.{module_name}.port=8081 )。 例如,module1始终托管在localhost:8888,而module2始终托管在localhost:8889。 看到这个答案 。 使用Fiddler将localhost与每个模块的端口绑定到自定义域。 例如,moule1.gaelocal.com指向localhost:8888,moule2.gaelocal.com指向localhost:8889。 看到这个答案 。 更新每个模块的web.xml并将.apphost.com替换为.gaelocal.com (或者只为两个环境使用.apphost.com )。