onbeforeunload() and onunload() have been tried, including the AJAX methods provided online.
onbeforeunload(), IE and Chrome support it, but the function cannot be executed. It can only return a prompt string. The onunload() method is not supported by Chorme and the IE effect is not good. Please give me some advice on whether there is a better method.
This is mainly used for users to judge whether they are online or offline. Method to prevent the page from not being logged in after it is closed.
It would be great if I could show you the code
I solved it with cooking.
Use websocket long link, the PHP side monitors the socket port number, the session is saved in the database, and the PHP side clears the session record in the database after disconnection.
Already solved