Java:Why http session is not destroyed when tab or browser is closed?

后端 未结 8 1717
-上瘾入骨i
-上瘾入骨i 2020-12-06 00:54

I have the following implementation of HttpSessionlistener

public class SessionListener implements HttpSessionAttributeListener, HttpSessionListener {


publ         


        
8条回答
  •  佛祖请我去吃肉
    2020-12-06 01:33

    Session objects live in the server and are controlled by the server. Only the server can create or destroy sessions. So if the client is closed the session lives until it expires. The client can only suggest to the server that it can destroy some session. This request must be explicit somehow. Hence, when you close a browser window, there's no implicit request to the server informing that it must destroy a given session.

提交回复
热议问题