Home > Web Front-end > JS Tutorial > body text

Code to determine whether the user is online_javascript skills

WBOY
Release: 2016-05-16 18:09:53
Original
1476 people have browsed it

Consider two situations:
(1) The user closes the browser or is redirected to other web pages

Copy the code The code is as follows:



Explanation: null.php is used to set the user status to offline
(2) The user no longer browses this website for a long time
Idea: Create a table active_stat with attributes including userid, lasttime, and nowtime. Every time the user opens this website, change lasttime to the current time now(), change nowtime to the current time every 1 minute, and determine whether nowtime-lasttime is greater than 20 minutes. If it is greater, modify the user status to offline
Copy code The code is as follows:

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template