By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,723 Members | 1,876 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,723 IT Pros & Developers. It's quick & easy.

How can i detect the actions of person visiting my site ?

P: 3
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 ?
Feb 27 '08 #1
Share this Question
Share on Google+
12 Replies


hsriat
Expert 100+
P: 1,654
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 ?
I don't know about this site, but if you have to do something like this.
  • Make a table, say current_activities, 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.
Feb 27 '08 #2

Markus
Expert 5K+
P: 6,050
I don't know about this site, but if you have to do something like this.
  • Make a table, say current_activities, 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.
That'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.
Feb 27 '08 #3

hsriat
Expert 100+
P: 1,654
That'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.
Feb 27 '08 #4

Markus
Expert 5K+
P: 6,050
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.
Indeedy, doody.

See what we can do when we work together?
It's beautiful!
Feb 27 '08 #5

hsriat
Expert 100+
P: 1,654
Indeedy, doody.

See what we can do when we work together?
It's beautiful!

Yeah, it is...

PS: What's doody?
Feb 27 '08 #6

Markus
Expert 5K+
P: 6,050
Yeah, it is...

PS: What's doody?
Urm, well... it just rhymes :D
Feb 27 '08 #7

hsriat
Expert 100+
P: 1,654
Urm, well... it just rhymes :D

oh... ok.. thats goody doody!
Feb 27 '08 #8

Markus
Expert 5K+
P: 6,050
oh... ok.. thats goody doody!
This thread has officially been h i j a c k e d

:P
Feb 27 '08 #9

harshmaul
Expert 100+
P: 490
Thats the third thread hijak that i've witnessed in two days!
Feb 27 '08 #10

hsriat
Expert 100+
P: 1,654
Thats the third thread hijak that i've witnessed in two days!
I know, and the first one was mine!!

So taking revenge here. :D
Feb 27 '08 #11

Markus
Expert 5K+
P: 6,050
Thats the third thread hijak that i've witnessed in two days!
You better watch it!
Or we'll be hijacking you
*evil*
Feb 27 '08 #12

ronverdonk
Expert 2.5K+
P: 4,258
Could we please all get back to the problem here?

moderator
Feb 27 '08 #13

Post your reply

Sign in to post your reply or Sign up for a free account.