I am using in older FuseBoxish style- this segment comes from my
app.globals.  It was pretty much stolen from the article in CFDJ.  

I have used a similar technique with lists to make a web-based chat session
that does not use a DB at all.  It is remarkably stable for relying on META
refresh.  it is also fuseboxish.


<cflock name="APPLICATION.SessionTracker" type="EXCLUSIVE" timeout="20"
throwontimeout="Yes">
   <!---  If session-tracker does not exist generate it --->
   
   <Cfparam name="APPLICATION.SessionTracker"  default=#structnew()#>
   <!--- Log current User --->
   
   <cfset dummy =StructInsert(APPLICATION.SessionTracker,
CGI.REMOTE_ADDR,now(),true)>
   
</cflock>


And this segment is on a page of its own called dsp_session.cfm.  It calls
itself over and over in the fuse so I can watch people come and go.  I'm not
sure why it includes app_gloabls again.  I was still cutting my teeth on a
lot of stuff so the code is kinda lame.  -Nate

<cfinclude template="app_Globals.cfm">


<html>
<head>
  <title>Live Session-Tracker Report</title>
  <meta http-equiv="REFRESH" content="45;url=index.cfm?fuseaction=MONITOR">
</head>
<body><basefont face="Arial">
<cfinclude template="incl_header.htm">
<cfinclude template="incl_dateline.cfm">
<cfinclude template="incl_menu.cfm">


<cfoutput>

<h3>Live Session-Tracker Report</h3>
#dayofweekasstring(dayofweek(now()))#, #Monthasstring(month(now()))#
#day(now())#, #YEAR(now())# #Timeformat(now(),"hh:mm:ss tt")#
<cflock name="#APPLICATION.applicationName#" 
        type="Exclusive" 
        timeout="20" 
        throwontimeout="Yes">

   <table border="2" cellspacing="0" width="95%">
   <tr bgcolor="##cccccc">
      <td><b>User (by IP-address)</b></td>
      <td><b>Session-Status</b></td>
   </tr>

   <CFLOOP collection=#APPLICATION.SessionTracker# item="aUser">
      <cfset onlineSince = StructFind(APPLICATION.SessionTracker, aUser)>
      
      <CFIF DateCompare(onlineSince+theTimeout, Now()) EQ 1>
      <!--- User last activity lies within session-timeout, 
            so his/her session is active --->

         <cfset inactiveSince = DateDiff("n", onlineSince, Now())>

         <!--- The threshold for coloring the report 
               may be set individually: --->
         <cfif inactiveSince LTE 2>
            <cfset theColor = "Cyan">
         <cfelseif inactiveSince LTE 5>
            <cfset theColor = "Yellow">
         <cfelse>
            <cfset theColor = "Red">
         </cfif>

         <!--- Output of current user in report --->
         <tr>
            <td bgcolor="##eeeeee">#aUser#</td>
            <td bgcolor="#theColor#">
               inactive since <b>#inactiveSince#</b> mins
            </td>
         </tr>
      
      <CFELSE>
      <!--- User�s session has timed-out, so we can 
            delete his IP from the Session-Tracker --->

         <cfset dummy = StructDelete(APPLICATION.SessionTracker, aUser)>

      </CFIF>
   </CFLOOP>

   </table><p>
   #StructCount(APPLICATION.SessionTracker)# Users online </p>

</cflock>

</cfoutput>
</body>
</html>
<cfinclude template="incl_bottom_edge.htm">
<cfinclude template="incl_spacer_row.htm">

-----Original Message-----
From: Steve Bryant [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 28, 2002 2:24 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Trying to display users currently on-line


There is an article in an old issue of CFDJ that covers this. I don't have 
the issue handy, but if I recall correctly, it said to store session 
information in a structure (or array, I can't remember) in the Application 
scope. I don't know if that helps much.

At 12:45 PM 3/28/2002 -0600, Brian Brown wrote:
>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


Steve Bryant
Web Developer
TIDF.com
303-893-6628 x12

==^================================================================
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