I've a technique but what is best technique for it? My technique is Create a active name table and within table, create a user_id active columns. If users are click on turn on active where turn on == active it display online or not. What is best idea than it.
Asked
Active
Viewed 94 times
2 Answers
2
This technique will not work if the user closes the page and it will still showing active regardless whether the user is no longer online. Another approach you can do is log the user’s last activity timestamp and if the time between the last activity is less than 5 minutes from now then showing user as online or else showing user as offline.

Ralph
- 2,065
- 3
- 15
- 23
-
1this should be in comment... – Sagar Naliyapara Jul 28 '15 at 06:19
0
One should destroy the table data using ajax as soon as the window gets closed. More on this read @ window.onclose function

Community
- 1
- 1
-
Thanks. I like to use session for it. If session is active in browser the active in table or not set session inactive. This is true. Nor what is the best trick for it? – Dipendra Thapa Jul 28 '15 at 15:38
-
Same, When user logged in then will start session and active on users table. And when user logout or close the browser the session will automatically destroy or unset then will offline. – Dipendra Thapa Sep 19 '15 at 03:35
-
If you like to use switch of online and offline, you'll better to use another session of name. – Dipendra Thapa Sep 19 '15 at 03:37
-
Actually I am not good in php programming. It is my logic. Good luck to all php programmer. – Dipendra Thapa Sep 19 '15 at 03:38