How to logout my application when I closed the window?

后端 未结 9 1938
猫巷女王i
猫巷女王i 2020-12-15 13:33

In my chat application i am having the logout button and it works fine.

Now I need to logout the application when I closed the browser window also..How can I achieve

9条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-15 14:09

    There is no exact way to do this with the clientside. There is no event that is fired when the page is exited. It should be done with the Session End event on the server.

    You can try to use onbeforeunload or unload, but race conditions will prevent that from happening. AND they do not fire for browsers crashing, lost internet connection, etc.

提交回复
热议问题