somethingJava is a website design company that specializes in development of content managed websites at an affordable cost. Web design for all, to us, means we can fit the needs of small to enterprise businesses.
   To learn more about bluApple click here

bluApple ColdPress current release 2.5
Blogs
Posted: 06/06/2010 at 2:00 PM by Marco Williams
Tags: coldfusion,sessions
So I was messing around trying to figure out a way to see specific session data from an application standpoint.  I found a blog somewhere, it wasn't 100% relevant but it did have a snippet of code that I found interesting.   So I put this to use and this is what I came up with and it seems to work pretty well.

The important thing here is to know what your application name is.
Mine in this case is "ba25_cms_sandbox1_0_05" 

	<cfset appname = "ba25_cms_sandbox1_0_05" >

This is where the magic seems to happen. Looks like were connecting to a built in coldfusion runtime feature called "SessionTracker".
I don't exactly know how well this will work on third party hosting, but it's worth a try. If it works I'll update this blog and let you know.

    <cfscript>
        sessiontrackerObj= createObject('java','coldfusion.runtime.SessionTracker');
        activesessions = sessiontrackerObj.getSessionCollection('#appname#');
        nosessions=ListLen(structkeyList(activeSessions));
    </cfscript>

"nosessions" will give you the number of active sessions. You can also loop though the structkeylist and see specific information about each session.

    
    <cfloop collection="#activesessions#" item="name">
        <cfset singleSession = activeSessions[name] >
        <cfdump var="#singleSession#">
    </cfloop>


And there you have it. You can now see what sessions are active at any given time in your application. If you have questions, feel free to comment or use the askSomethingJava form.

Comments:

No Comments have been posted.

Add a Comment:








You may post code in your comments by surrounding it with [code] and [/code]
Notify me of follow-up comments via email.


The Archive:
I originally built bluApple as a personal utility to rapidly produce websites. Over several years it has slowly grown into a respectable CMS tool. I feel that with support from the community, bluApple Coldpress can become a contender as one of the top CMS products on the market.

Marco G. Williams
Lead Developer & CEO