I explored these undocumented functions in detail, and I think they
have an unfortunate side effect of keeping sessions alive. Getting the
overall count is fine, but any access to any session variable updates
the last accessed time, which resets the clock when it comes to timing
out the session. If you call the code too much, the sessions will be
stuck in RAM.

I used two sessions (one in Firefox and one in MSIE) when testing. One
session ran code which output the session[i].cfid for every active
session, the other session was logged into the site, which has a
session existence check at the top of every page. The session timeout
was set to 10 seconds.

If I logged into the site, did not click anything for 20 seconds, then
clicked a link, I would get thrown out to the login page, as expected.
If I logged into the site, did not click on anything for 5 minutes,
but repeatedly ran the page which reported on all active sessions
using the other session, then the main session that was logged in
would stay logged in.

This side effect makes the SessionTracker unusable when it comes to
creating a session management feature. I confirmed that just reporting
the count did not cause the sessions to stay alive. So if you just
want a count, you are all set. If you want to actually look inside the
active session variables, such as determining which sessions are
logged in, then you should create your own session management
structure, similar to what is listed in the Ray Camden link in an
earlier email.

I tested using CFMX 7.0.2 chf2 on Windows 2003. Maybe CFMX 6 was different.

-Mike Chabot

On 4/18/07, Joel Watson <[EMAIL PROTECTED]> wrote:
> Thanks, this works great!
>
> I really appreciate your help, as well as the responses from everyone else!
>
> Joel
>
> >Here you go Joel, I got this code from someone else long ago, and now am
> >passing it on to you. =) You may store other data about them, but you
> >can go from here.
> >
> >
> ><cfapplication name="yourApplicationName">
> >
> ><cfscript>
> >sessiontrackerObj=
> >createObject("java","coldfusion.runtime.SessionTracker");
> >activesessions =
> >sessiontrackerObj.getSessionCollection(application.applicationname);
> >nosessions=ListLen(structkeyList(activeSessions));
> ></cfscript>
> ><cfoutput>
> ><h3>Total Sessions : #nosessions#</h3>
> ></cfoutput>
> >
> ><cfoutput>
> >       <table>
> >               <tr>
> >                       <td>Username</td>
> >                       <td>Login Date</td>
> >                       <td>IP Address</td>
> >               </tr>
> >       <cfloop list="#structkeyList(activeSessions)#" delimiters=","
> >index="i">
> >               <cfif structKeyExists(activesessions[i], "fullname")>
> >               <tr>
> >                       <td>#activesessions[i].fullname#</td>
> >                       <td>#dateFormat(activesessions[i].loginDate,
> >"short")# #timeFormat(activesessions[i].loginDate, "short")#</td>
> >                       <td><cfif structKeyExists(activesessions[i],
> >"ip")>#activesessions[i].ip#</cfif></td>
> >               </tr>
> >               </cfif>
> >       </cfloop>
> >       </table>
> ></cfoutput>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create Web Applications With ColdFusion MX7 & Flex 2. 
Build powerful, scalable RIAs. Free Trial
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJS 

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:275790
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to