Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CF: Application Scope Dump #snippet
<cfset pageclass = "allapps">
<cfsetting requesttimeout="1000">
<br>
<cfparam name="url.sessdump" default="false">
<cfset Cfapp_list = createObject("java","coldfusion.runtime.ApplicationScopeTracker")>
<!--- <cfdump var="#CFAPP_list#"> --->
<cfset appIterator = CFAPP_list.getApplicationKeys() />
<cfset oSession = createObject("java","coldfusion.runtime.SessionTracker")>
<cfif isdefined("url.an")>
<cfdump var="#CFAPP_list.getApplicationScope(url.an)#">
<!--- <cfscript>
StructDelete(application,#url.an#);
</cfscript> --->
</cfif>
<cfif isdefined("url.sn")>
<cfdump var="#server#">
</cfif>
<cfif isdefined("url.ssn")>
<cffunction name="getApplicationSessionCount" returntype="numeric">
<cfargument name="appName" type="string" required="true">
<cfscript>
var mySessions = StructCount(oSession.getSessionCollection(arguments.appName));
return mySessions;
</cfscript>
</cffunction>
#Sessions <cfset appsessions = getApplicationSessionCount(url.ssn)><span <cfif appsessions gt "30">style="color: red;"</cfif>><cfoutput>#appsessions#</cfoutput></span>
<br />
<a href="<cfoutput>#script_name#?#cgi.query_string#</cfoutput>&sessdump=true">Show Session Data</a><br />
<cfif url.sessdump eq "true">
<!--- <cfdump var="#oSession#">
<cfflush interval="10">
<strong>oSession.getSessionKeys()</strong><br />
<cfdump var="#oSession.getSessionKeys()#">
<cfflush interval="10"> --->
<cfdump var="#oSession.getSessionCollection(url.ssn)#">
</cfif>
<cfelse>
# of Sessions: <cfoutput>#oSession.getSessionCount()#</cfoutput>
<cfset count = "0">
<table width="100%" cellspacing="3" cellpadding="3">
<cfloop condition=#appIterator.hasMoreElements()#>
<tr>
<cfset count = count + "1">
<cfset app_name = appIterator.nextElement()>
<cfif Trim(app_name) neq "">
<td>
<strong>
<cfoutput>
<cfif StructKeyExists(CFAPP_list.getApplicationScope(app_name),"datasource")>
#CFAPP_list.getApplicationScope(app_name).datasource# -
</cfif>
<cfif structKeyExists(CFAPP_list.getApplicationScope(app_name),"site_directory_name")>
#CFAPP_list.getApplicationScope(app_name).site_directory_name#
</cfif>
</cfoutput>
</strong>
</td>
<td>#Ses. <cfset appsessions = StructCount(oSession.getSessionCollection(app_name))><span <cfif appsessions gt "30">style="color: red;"</cfif>><cfoutput>#appsessions#</cfoutput></span></td>
<td><cfoutput>#app_name#</cfoutput></td>
<td><cfoutput><a href="#cgi.script_name#?an=#app_name#">View Applicaiton</a></cfoutput></td>
<td><cfoutput><a href="#cgi.script_name#?ssn=#app_name#">View Session Vars</a></cfoutput></td>
</cfif>
</tr>
<cfflush interval="10">
</cfloop>
</table>
<br><cfoutput>#count#</cfoutput> application running.
</cfif>
<!--- <cfset CFAPP_list = createObject("java","coldfusion.runtime.ApplicationScopeTracker")> --->
<!--- <cfdump var="#CFAPP_list#"> --->
<!--- <cfset appIterator = CFAPP_list.getApplicationKeys() />
<cfloop condition=#appIterator.hasMoreElements()# >
<cfoutput>#appIterator.nextElement()#</cfoutput>
</cfloop>
--->
<!--- CFAPP_list.getApplicationScope("#session.site_guid#")<br> --->
<!---
<cfapplication name="">
<cfdump var=#application#><cfabort>
--->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.