faqts : Computers : Programming : Languages : Asp : ASP/VBScript : Common Problems : Not Quite ASP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 25 people (24%) answered Yes
Recently 4 of 4 people (100%) answered Yes

Entry

I have a simple chat room on my site running through ASP. How do I show who's logged on at any time?

Mar 12th, 2003 12:31
Chris White, ger cotter,


You could add the user name as an Application variable at log-on time. 
E.g.
<%
'login 
' userid = username of current user
Application("@User_" & userid) = now()
Session(userid) = now
%>
then to display list of current users use this 
<%
for each content in Application.Contents
  If Left(content, 6) = "@User_" Then
    ' User, print user name
    Response.write(Right(content, Len(content) - 6))
  Else
    ' other application variable, ignore
  End If
next
%>
Youll need to add the following code to your global.asa or logout 
screen
<%
' in logout.asp
Application.Contents.Remove(session("userid"))
Session.abandon()
' in global.asa
Sub Session_OnEnd
  If Session("userid") = "" Then
    Application.Contents.Remove(session("userid"))
  End If
End Sub
%>



© 1999-2004 Synop Pty Ltd