Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to build a Who Is Online feature?

Status
Not open for further replies.

emillen

Technical User
Joined
May 29, 2004
Messages
2
Location
CA
Hi,

I build an ASP admin app to manage my site. There are about 50 users who login regularly. I want to display a list of who is currently online. When user login, I can record them to an array in Application variable. Problem: user don't always press login button to logout so I cannot remove them from array of currently online users. Any help would be great.

E.
 
Store their last time of activity in the database. So on every page you update that users data in the database setting their last activity time to Now. Then you can do a select on all users who's last activity was within say the past 10 minutes. e.g.
<%
'Update current user's time
conn.execute("update tbl_user set activitytime=" & Now())

'Get users who have been active in the past 10 mins
set rs=conn.execute ("select * from tbl_user where activitytime=>" dateadd("m",10,Now()))
%>
Then just run through the recordset for the list of people active in the past 10 minutes

 
also in global you can use session_onend to log them out, have to wait for the session to time out tho, and it's not entirely reliable, also in the pages where you have login/logout, you can use javascript to launch a temp window to log them out
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top