How to end sessions automatically if user closes the browser

前端 未结 6 1325
孤街浪徒
孤街浪徒 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

    You need to set the session timeout, that is, the time after which current Session object will be invalidated.

    This can be done either by setting timeout in your web.xml like:

    
        20
    
    

    or programmatically call on the Session object

    session.setMaxInactiveInterval(valueInSeconds);
    

    Keep an eye that session timeout period set up in web.xml is in minutes, and programmatically - in seconds.

提交回复
热议问题