I created an application-based query object.  In it, I have the
username, last page viewed, session id, and time last viewed.


Then, I can easily get a report of who has been on what page at what
time.  My site traffic isn't as heavy as yours, but I haven't seen any
performance issues that would make me want to remove this feature.

________________________________

From: Katz, Dov B (IT) [mailto:[EMAIL PROTECTED]
Sent: Monday, August 09, 2004 8:23 AM
To: CF-Talk
Subject: RE: Count logged in user sessions

Does anyone know the performance cost of things like the SessionTracker
code?

Without sessionTracker, I wanted to do something similar, but in my
case, I wanted to make a struct for each session, put it in the session,
and in the application, and then access it from both, for some realtime
updates.  I have a site which gets 400K-500K page views a day, and I am
looking to minimize the impact of advanced session management.

Example pseudocode:

( Application.cfm  - extra code to support being logged in multiple
times )
param application.allUsers default=structnew()
IF I am logged in
    update my username struct (which allows me to have multiple sessions
per username )
    ( application.allUsers
[session.myUserName].[session.urlToken].lastAccess=now() )
END IF
   
( in post-login success code )
     
    myStruct=new CF struct();
    myStruct.lastAccess=now();
    IF (session.MyUsername is NOT a key in application.allUsers)
        application.allUsers[session.myUsername]=new cfstruct();
    END IF
    application.allUsers[session.myUsername] [
session.urlToken]=myStruct;
   
    // this struct holds other realtime info, but since its not a direct
session var, it will get orphaned when a session dies, and cleaned up by
my cleanup loop run periodically...
    session.myStructRef=myStruct;

Now I can loop through Application.allUsers, and loop through all child
structures, to clean it out, and count user instances, etc...

  _____  

From: Raymond Camden [mailto:[EMAIL PROTECTED]
Sent: Monday, August 09, 2004 8:44 AM
To: CF-Talk
Subject: Re: Count logged in user sessions

There are a few different ways to do this. There is a ServiceFactory
method that will help. This article,
http://www.findarticles.com/p/articles/mi_m0MLU/is_10_5/ai_109039749,
written by myself, shows code that Sam Neff wrote. You can also do
tracking in application.cfm by doing (pseudo-code)

param application.sessions
application.sessions[session.urltoken] = now();

What this does is create one record per session in an application
struct. It uses the current time as the value. When you count the
sessions, you simply remove any session who has a value more then your
timeout, normally 20 minutes. This will give you the current number of
sessions.

On Sat, 7 Aug 2004 18:52:50 -0400, Ewok <[EMAIL PROTECTED]> wrote:
> Doesn't look like this came through the first time... if its double
posted you can hang me by my ... ummm...parts
>
> This has got to be possible. Seems like I remember the question being
asked before but can't seem to word it right in the archives to get any
results. Anyone know a link or a solution?
>
> I am using sessions to log people in and keep them logged in. There
must be a way to count active sessions right? I just need a number, I
don't plan to pull specific data about users who are logged in......
although it would be nice to know that too : )
>
>
  _____
________________________________
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to