Ooooh... So then something like this, what you are going to have to do is setup some type of timeout within the application[session.struct]. Here is a snippet I got from the bacfug a while back. It's pretty easy to read and basically keeps live session stats based on a Garbage Collection Timeout interval. This tag would essentially get called OnRequestEnd.cfm, and that way your application variable will always contain only live sessions, on garbage collection, it loops through the application structure and compares dates to deal with session timeout. I think I still have the example app, I can show you an example of this if you need more help with this.
HTH,
Robert Hinojosa
Senior WebDeveloper
Senior Principal Consultant
[EMAIL PROTECTED]
www.hencie.com
972-671-0011 ext.284
<!--- DEFAULT ATTRIBUTES --->
<CFPARAM NAME="attributes.name" default="sessions" type="variableName">
<CFPARAM NAME="attributes.sessiontimeout" default="#createtimespan(0,1,0,0)#">
<CFPARAM NAME="attributes.garbageInterval" default="5">
<!--- MAKE THE NAME LOCAL FOR EFFICIENCY --->
<CFSET name = attributes.name>
<!--- INITIALIZE A STRUCTURE TO HOLD THE SESSIONS --->
<CFPARAM NAME="application.#name#" DEFAULT="#structnew()#">
<!--- LOCK THE WRITES TO THE SESSION --->
<CFLOCK NAME="SessionsCollectWrite" TIMEOUT="15">
<!--- PUT THE SESSION INTO THE APPLICATION STRUCTURE --->
<CFSET application[name][session.sessionID] = session>
<!--- UPDATE THE SessionsCollectLastVisited KEY TO now() TO DEAL WITH TIMEOUTS --->
<CFSET application[name][session.sessionID].SessionMagicCollectorLastVisited = now()>
</CFLOCK>
<!--- INITIALIZE A VARIABLE TO KEEP TRACK OF GARBAGE COLLECTION INTERVAL --->
<CFPARAM NAME="application.SessionMagicCollectorLastGarbageCollection" DEFAULT="#now()#">
<!--- IF THE GARBAGE COLLECTION INTERVAL HAS PASSED SINCE LAST COLLECTION, CLEAR OUT DEAD SESSIONS BASED ON THE TIMEOUT --->
<CFIF dateDiff("n",application.SessionMagicCollectorLastGarbageCollection,now()) GTE attributes.garbageInterval>
<!--- LOOP THROUGH ALL OF THE SESSIONS. IF THE LAST TIME THEY WERE VISITED IS LONGER AGO THAN THE SESSION TIMEOUT, KILL IT --->
<CFLOOP COLLECTION="#application[name]#" ITEM="TheSession">
<CFIF DateCompare(now() - attributes.sessiontimeout,application[name][TheSession].SessionMagicCollectorLastVisited) GT - 1>
<CFSET StructDelete(application[name],TheSession)>
</CFIF>
</CFLOOP>
<!--- UPDATE THE GARBAGE COLLECTION TIME TO NOW, LOCKED TO PROTECT CONCURRENCY --->
<CFLOCK NAME="SessionsCollectUpdateLastGarbageCollection" TIMEOUT="15">
<CFSET application.SessionMagicCollectorLastGarbageCollection = now()>
</CFLOCK>
</CFIF>
:-----Original Message-----
:From: Joshua Meekhof [mailto:[EMAIL PROTECTED]]
:Sent: Tuesday, April 24, 2001 2:59 PM
:To: [EMAIL PROTECTED]
:Subject: Re: session implementation
:
:
:Robert,
:
:This information is already available to me because
:session.sessionid
:(or something like that) contains the application
:name. Besides, the
:information that provides doesn't do what I want it
:to. I would like to
:be able to look at _ALL_ sessions, and determine which
:keys to remove
:from the application based upon the sessions that have expired.
:
:It sounds similar to what Marlon Moyer is trying to do
:with finding out
:how many current sessions are open.
:
:--
:Josh
:
:-------------------------------------------------------
:------------------
:This email server is running an evaluation copy of the
:MailShield anti-
:spam software. Please contact your email administrator
:if you have any
:questions about this message. MailShield product info:
:www.mailshield.com
:
:-----------------------------------------------
:To post, send email to [EMAIL PROTECTED]
:To subscribe / unsubscribe: http://www.dfwcfug.org
:
