How to end sessions automatically if user closes the browser

前端 未结 6 1327
孤街浪徒
孤街浪徒 2020-12-10 09:12

I need to end the session automatically when the user is inactive for some particular time say for 10 minutes. We have a method in

HttpSession session=reque         


        
6条回答
  •  庸人自扰
    2020-12-10 09:27

    Question: How to end sessions automatically if user closes the browser?
    Answer: Set max inactive interval time value less than 0.

    Example:

    HttpSession session = request.getSession();
    session.setMaxInactiveInterval(-1);
    session.setAttribute("User", au);
    response.sendRedirect("doLogin.jsp");
    

提交回复
热议问题