PHP program can have webpage close event User login can write logs
How to use PHP to query and write logs when a user leaves (closes the webpage)
Reply to discussion (solution)
Should not
This can only be judged by js and passed to php for processing.
Php cannot be detected.
When you close your browser, you can trigger the window. onbeforeunload event. you only need to do something in this event...
Listen to events with js, and then request the php interface. If php is used separately, it cannot be detected.
If the execution has been completed, no.
The connection_aborted function can be used in execution to determine
It turns out that the browser is not directly closed and how to record the exit log.
I don't think JS works either. If there are multiple windows, how do you know if it is the last window? if it is not the last window, it is not the exit. You can change your mind to update the user status during each operation: The Last activity time.