Clearing SESSION variables when a tab is closed

前端 未结 3 586
甜味超标
甜味超标 2021-01-20 03:39

I need to clear the session variables when the tab is closed but I could not find any solutions so far. The closest I have got is by using the \"onbeforeunload\" function is

3条回答
  •  后悔当初
    2021-01-20 04:10

    There is no secure way of handling what you are looking for. onbeforunload event executes every time you leave the page. (I had similar problem like this yesterday for one of my projects). The closest you can get is to control how the users leave the page.

    See this link posted by lan in some of the comments. And check the answer by Daniel Melo That is as close you can get with the solution from this problem.

    I also found this link but its basically the extraction of the answers given in stackoverflow.

    Hope this helps.

提交回复
热议问题