How do I know whether the user is online?

0 Ng Chung pang · June 25, 2015
who can help me solve this question, can use the PHP or JQuary.

Post a Reply


Oldest  Newest  Rating
+1 Alan Johnson · June 25, 2015
Use a php session to determine if a single user is logged in.

For a list of all user's online you'll want to use a database.
+1 ahmed sabry · June 26, 2015
by using session in PHP 

it's very easy 

good luck 
+1 Sachin Kumar · July 8, 2015
Basic version :
1) Create a separate column/table X for user visibility (Use Boolean as date type -> 0 for offline and 1 for online)
2) When user creates an account then by default X will have the value 0
3) then when the user will logs in then change the value of X for this user to 1
In this way you will know when and how many users are online, you can also add additional row in X like last login time and etc

and when users logout then change the value of user visibility to 0 again.
0 Ng Chung pang · July 11, 2015
if the user is close the browser window  , they was not use the logout function ,so not can show the user logout , that  how to do it?
0 Sachin Kumar · July 11, 2015
The best way which I have found to tackle that problem is to make separate column for with title USER_LAST_ACTIVITY (with INT data type) and whenever user  do ANY sort of activity like changing the page, liking, commenting etc just store the timing in the same column.

then next step will be to create a php code so that whenever the any user open your website the code will check every user who were online and their last activity time and if the last activity time is greater than 30min or 1hr .. then make the user online status 0 and you will have a complete user online program
  • 1



Server-side, HTML embedded scripting language used to create dynamic Web pages.