cookie+session,会话时间设定。浏览器关闭。

    xiaoxiao2021-03-25  85

    原文:http://www.cnblogs.com/jarl/p/5892996.html

    HttpSession session = request.getSession();

     session.setAttribute(user, user); 

    session.setMaxInactiveInterval(2 * 3600); // Session保存两小时

    Cookie cookie = new Cookie("JSESSIONID", session.getId());

     cookie.setMaxAge(2 * 3600); // 客户端的JSESSIONID也保存两小时

    session.setMaxInactiveInterval(interval);

    cookie.setPath("/");

     response.addCookie(cookie);

    转载请注明原文地址: https://ju.6miu.com/read-14181.html

    最新回复(0)