Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How to track the total number of logged in members
Old 06-24-2005, 06:55 AM How to track the total number of logged in members
Novice Talker

Posts: 12
Trades: 0
I am currently working on a membership based web site. I need to display the number of members

logged in that system. To do this I have set a flag in the database which is set to 1 whenever a

user is logged in the system and when the user clicks on the ‘Log Out’ link a query is fired that

sets the same flag to 0. To display the total number of logged in members I run a query that counts

the number of records whose flag is set to 1.

However this method has a major shortcoming. When users do not click the ‘Log Out’ link but just

close the browser. In such a situation the query that will set the flag field back to 0 will bot be

fired and hence the user would be seen as active in the system even though the user has already left

the system.

When one company is viewing the profile of another company in my site I also need to show whether

that representative of the company whose profile is being viewed in logged in the system at that

time or not so that if the user wants then can send a message to them.

I need some advice on how can I achieve this in the best possible way, where I can display the total

number the total number of correct logged in members

Thanks a lot!

Cheers
Paresh
jeephp is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-24-2005, 07:00 AM
Rufo's Avatar
Extreme Talker

Posts: 173
Trades: 0
Add a column called something like "lastactivity", and whenever a user loads a page, update their "lastactivity" value to be the current timestamp. Then, when you want to get the number of logged in users, count all rows where the "lastactivity" value is within (e.g.) 5 minutes of the current system time, i.e. those users who have loaded a page in the last 5 minutes.

Rufo.
__________________

Please login or register to view this content. Registration is FREE
Rufo is offline
Reply With Quote
View Public Profile Visit Rufo's homepage!
 
Reply     « Reply to How to track the total number of logged in members
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.28047 seconds with 12 queries