Brian,
 
I did something like that for a site, which simply runs of a set session name (session.username) when the user logs in.
Here's the code:
 
----------------------------------------------------------------------------------------
<cfparam name="session.username" default="">
<!---Does the Application.Online variable exist yet?--->
<cflock name="Tracker" type="ReadOnly" timeout="5">
  <cfif IsDefined("Application.Online")>
    <cfset CreateStructure=FALSE>
  <cfelse>
    <cfset CreateStructure=TRUE> 
  </cfif>
</cflock>
 
<!---Create Application.Online (once only)--->
<cfif CreateStructure>
  <cflock name="Tracker" type="Exclusive" timeout="5">
    <cfset Application.Online=StructNew()>
  </cflock>
</cfif>
 
<!---Remove "old" users ("TimeOut Minutes")--->
<!---First build a list of users "older" than "TimeOut"--->
<cfset TimeOut=20>
<cfset UserList="">
<cflock name="Tracker" type="ReadOnly" timeout="10">
  <cfloop collection="#Application.Online#" item="ThisUser">
    <cfif DateDiff("n",Application.Online[ThisUser][1],now()) GTE TimeOut>
      <cfset UserList=ListAppend(UserList,ThisUser)> 
    </cfif>
  </cfloop>
</cflock>
 
<!---Then delete "old" users--->
<cfloop list="#UserList#" index="ThisUser">
  <cflock name="Tracker" type="Exclusive" timeout="5"> 
    <cfset Temp=StructDelete(Application.Online,ThisUser)>
  </cflock>
</cfloop>
----------------------------------------------------------------------------------------
I dropped this into my fbx_settings file on the root, and waa la.
You now have a collection to Loop called: application.online of the users who are logged into your site.
 
Hope was of assistance.
 
Josh Carrico
 
-----Original Message-----
From: Brian Brown [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 28, 2002 1:45 PM
To: [EMAIL PROTECTED]
Subject: Trying to display users currently on-line

Does anyone have any ideas about how to display the total active users on-line. Can it be done useing the CGLOBAL or the CDATA table? Or, do I need to set up a db table to track active users. Any help would be much appreciated.
 
Thanks
Brian
==^================================================================
This email was sent to: [email protected]

EASY UNSUBSCRIBE click here: http://topica.com/u/?bUrFMa.bV0Kx9
Or send an email to: [EMAIL PROTECTED]

T O P I C A -- Register now to manage your mail!
http://www.topica.com/partner/tag02/register
==^================================================================

Reply via email to