GWT:登录记住我

时间:2013-03-14 18:59:54

标签: session gwt login

我试着理解这个Login example
有一个名为“checkWithServerIfSessionIdIsStillLegal”的程序 我想知道服务器如何验证会话是否仍然有效,因为当用户关闭浏览器时会话ID总是不同的。
有人可以解释一下这是如何工作的?

2 个答案:

答案 0 :(得分:0)

通过在onModule加载中设置会话ID(当他logs in时)作为cookie并在访问登录页面后再次检查。

         String sessionID = result.getSessionId();
         final long DURATION = 1000 * 60 * 60 * 24 * 1;
         Date expires = new Date(System.currentTimeMillis() + DURATION);
         Cookies.setCookie("sid", sessionID, expires, null, "/", false);

以下是您所指的checkWithServerIfSessionIdIsStillLegal()的完整实现。

答案 1 :(得分:0)

请看以下链接。

Cannot use same cookie for multiple GWT applications

这可能会解决您的问题。