I have seen in this site that you can find out wether the person is online or offline or if he is online on which page he is ? How can I do that for my site ?
How can i detect the actions of person visiting my site ?
Collapse
X
-
Tags: None
-
Originally posted by KhannaNeetaI have seen in this site that you can find out wether the person is online or offline or if he is online on which page he is ? How can I do that for my site ?- Make a table, say current_activit ies, in the database with three fields, user_id, status and last_activity.
- When a user logs on to your site, update the status field.
- Every time a user visits a page, you may be doing a cookie validation thing. While you do that, update the last_activity field.
- And when a user logs out of your site, turn off the status flag.
Thats what I can suggest. Actual algorithm may be something else. -
Originally posted by hsriatI don't know about this site, but if you have to do something like this.- Make a table, say current_activit ies, in the database with three fields, user_id, status and last_activity.
- When a user logs on to your site, update the status field.
- Every time a user visits a page, you may be doing a cookie validation thing. While you do that, update the last_activity field.
- And when a user logs out of your site, turn off the status flag.
Thats what I can suggest. Actual algorithm may be something else.
But what if the user doesn't log out and just exists the browser?
You'd be smart to take the time of the users last activity, and when showing a page which shows said users last activity, check this time in your database with the current time, and if it is greater than, say, 1hour, declare the user offline and update the status accordingly.Comment
-
Originally posted by markusn00bThat's good logic, and exactrly how i'd go about it.
But what if the user doesn't log out and just exists the browser?
You'd be smart to take the time of the users last activity, and when showing a page which shows said users last activity, check this time in your database with the current time, and if it is greater than, say, 1hour, declare the user offline and update the status accordingly.
Yeah, you are right :)
Actually I didn't think about in deep. :p
Then we can also do one change. Instead of status flag, use time only. Don't update the status field with YES or NO, but update it with time. After one hour (or how much required), if user not logged out, declare him logged out. Else if he actually logs out, clear the time.Comment
-
Originally posted by hsriatYeah, you are right :)
Actually I didn't think about in deep. :p
Then we can also do one change. Instead of status flag, use time only. Don't update the status field with YES or NO, but update it with time. After one hour (or how much required), if user not logged out, declare him logged out. Else if he actually logs out, clear the time.
See what we can do when we work together?
It's beautiful!Comment
-
Comment