User Guide
960 Chapter 5: Application.CFC Reference
• You must use the ApplicationScope parameter to access the Application scope. You cannot
reference the Application scope directly; for example, use
Arguments.ApplicationScope.myVariable, not Application.myVariable. Use a named lock
when you reference variables in the Application scope, as shown in the example.
• You can access the Server scope directly; for example, Server.myVariable.
• You cannot access the Request scope.
Sessions do not end, and the
onSessionEnd method is not called when an application ends. The
onSessionEnd does not execute if there is no active application, however.
Example
The following method decrements an Application scope session count variable and logs the
session length.
<cffunction name="onSessionEnd">
<cfargument name = "SessionScope" required=true/>
<cfargument name = "AppScope" required=true/>
<cfset var sessionLength = TimeFormat(Now() - SessionScope.started,
"H:mm:ss")>
<cflock name="AppLock" timeout="5" type="Exclusive">
<cfset Arguments.AppScope.sessions = Arguments.AppScope.sessions - 1>
</cflock>
<cflog file="#This.Name#" type="Information"
text="Session #Arguments.SessionScope.sessionid# ended. Length:
#sessionLength# Active sessions: #Arguments.AppScope.sessions#>
</cffunction>