我在寫我的SPring MVC Web應用程序。Servlet會話超時
我已將會話時間設置爲10080分鐘,等於1周。 現在我想保持用戶登錄每次他打開的瀏覽器:
sessionService.setcurrentUser(myuser);
HttpSession session = request.getSession();
Cookie cookie = new Cookie("JSESSIONID", session.getId());
cookie.setMaxAge(timeout);
response.addCookie(cookie);
如果我的cookie最大年齡是相同的會話超時?
cookie.setMaxAge(10080);
這是很好的做法嗎?
僅供參考,setMaxAge參數值是以秒爲單位,而會話超時以分鐘爲單位 - 你需要通過60乘以10080得到最終的結果你正在尋找。 – Vladimir 2012-02-19 21:13:37