How to detect if a user has logged out, in php?

后端 未结 12 2479
南笙
南笙 2020-12-06 02:19

After the user successfully logs in, I store login = true in database. But how do I check if the user logged out by closing the browser without clicking the logout button? A

12条回答
  •  情歌与酒
    2020-12-06 03:02

    You can do this with a combination of ways, 2 at the most i guess, with the one bothering on last activity, you combine it with using jQuery to check for inactivity, that is no mouse or keyboard events for some time, say about 10 to 20 mins, then once the idle time is confirmed, you make an ajax call to a php file that will update your database table showing user offline.

    You can start with:

       
    

提交回复
热议问题