Sorry, but I'm going to get a bit picky here. First, you use an
exclusive lock to check and define application.usersInfo. I believe it
will be a bit more gentle to break it up some:

<cflock scope="application" type="readOnly">
        <cfif not isDefined("application.usersInfo")>
                <cfset needInit = true>
        <cfelse>
                Mcfset needInit = false>
        </cfif>
</cflock>

<cfif needInit>
        Now do the exclusive lock and set the struct
</cfif>

Moving on - you have this code:

<cfset user_cfid = Evaluate(CFID)>

What in the heck is that? Are you copying session.cfid? Then why not

<cflock on session, readonly>
        <cfset user_cfid = session.cfid>
</cflock>

Not sure why you have the random named lock statement.

Later on...

      <cfif
       Evaluate(DateDiff("n", 
 StructFind(Application.UsersInfo, itmUser),
    Now())) GT 10>

Two problems here. You don't need Evaluate. You don't need structFind.

<cfif dateDiff("n",application.usersInfo[itmUser],now()) gt 10>

Just some suggestions. MX makes this a lot easier since you don't need
the lock statements. I have a CFC called SessionTracker that you can
download from my blog.

========================================================================
===
Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc
(www.mindseye.com)
Member of Team Macromedia (http://www.macromedia.com/go/teammacromedia)

Email    : [EMAIL PROTECTED]
Blog     : www.camdenfamily.com/morpheus/blog
Yahoo IM : morpheus

"My ally is the Force, and a powerful ally it is." - Yoda 

> -----Original Message-----
> From: Dave Lyons [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, May 27, 2003 11:08 PM
> To: CF-Talk
> Subject: Re: Number of users brownsing website
> 
> 
> in your application.cfm template
> 
> 
> <!--- start users online --->
> <!--- does the user already exist --->
> <CFLOCK SCOPE="Application" Timeout="15" type="Exclusive">
>   <cfif NOT isdefined("Application.UsersInfo")>
>      <cfset Application.UsersInfo = StructNew()>
>   </cfif>
> </CFLOCK>
> 
> <!--- reference the structure using UUID --->
> <cflock name="#CreateUUID()#" timeout="15" type="exclusive">
>     <cfset user_cfid = Evaluate(CFID)>
>     <cfset user_time = Now()>
> </cflock>
> 
> <!--- check to see if the user has already been counted ---> 
> <cflock timeout="15" type="exclusive" scope="application">
>   <cfif NOT StructKeyExists(Application.UsersInfo, user_cfid)>
>      <cfset temp = StructInsert(Application.UsersInfo, 
> user_cfid, user_time)>
>   </cfif>
> </cflock>
> 
> <!--- delete dormant or users that have left --->
> <cflock timeout="15" type="exclusive" scope="application">
>   <cfloop collection="#Application.UsersInfo#" item="itmUser">
>      <cfif
>       Evaluate(DateDiff("n", 
> StructFind(Application.UsersInfo, itmUser),
>    Now())) GT 10>
>      <cfset StructDelete(Application.UsersInfo, itmUser)>  </cfif>
>   </cfloop>
> </cflock>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> where you want to display it
> 
> 
> <!--- show active users --->
> <cflock timeout="10" type="exclusive" scope="application">  <cfoutput>
>   #StructCount(Application.UsersInfo)#  visitors currently 
> online  </cfoutput> </cflock>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> ----- Original Message -----
> From: "Blood Python" <[EMAIL PROTECTED]>
> To: "CF-Talk" <[EMAIL PROTECTED]>
> Sent: Wednesday, May 28, 2003 12:58 AM
> Subject: Number of users brownsing website
> 
> 
> > hi all.
> >
> > I've done a portal using FB3 for one of my clients and he wants to 
> > display the number of users browsing his website.
> >
> > I was thinking about using some session variables to do 
> that and put 
> > the code in the main fbx_settings.cfm. Maybe some of you guys have 
> > made something like that and could give me a better idea or 
> maybe some 
> > inputs
> or
> > tips about this.
> >
> > Best regards.
> >
> > BP.
> >
> > _________________________________________________________________
> > Add photos to your messages with MSN 8. Get 2 months FREE*. 
> > http://join.msn.com/?page=features/featuredemail
> >
> > 
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Get the mailserver that powers this list at 
http://www.coolfusion.com

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to