How to detect browser closing?

后端 未结 6 1569
故里飘歌
故里飘歌 2020-11-28 13:48

In my web app, when a user logs in, I add his Id to a vector of valid Ids in the servlet, when he logs out, I remove his Id from the vector, so I can see how many current us

6条回答
  •  一整个雨季
    2020-11-28 14:26

    I suggest you remove the ID when the Servlet engine destroys the session. Register a HttpSessionListener that removes the user's ID when sessionDestroyed() is called.

    Diodeus's idea will only help you detect that the session is over more immediately.

提交回复
热议问题