Created
March 25, 2014 10:47
Understanding Application And Session Timeouts In ColdFusion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfcomponent | |
output="false" | |
hint="I define the application settings and event handlers."> | |
<!--- | |
Define the application settings. Notice that our | |
Application timeout is rather small - 10 seconds, | |
while our Session timeout is larger - 5 minutes. | |
---> | |
<cfset this.name = hash( getCurrentTemplatePath() ) /> | |
<cfset this.applicationTimeout = createTimeSpan( 0, 0, 0, 10 ) /> | |
<cfset this.sessionManagement = true /> | |
<cfset this.sessionTimeout = createTimeSpan( 0, 0, 5, 0 ) /> | |
<!--- Define the request settings. ---> | |
<cfsetting showdebugoutput="false" /> | |
<cffunction | |
name="onApplicationStart" | |
access="public" | |
returntype="boolean" | |
output="false" | |
hint="I initialize the application."> | |
<!--- Initialize the application settings. ---> | |
<cfset application.dateInitialized = now() /> | |
<!--- Return true so that the page can load. ---> | |
<cfreturn true /> | |
</cffunction> | |
<cffunction | |
name="onSessionStart" | |
access="public" | |
returntype="void" | |
output="false" | |
hint="I initialize the session."> | |
<!--- Initialize the session settings. ---> | |
<cfset session.dateInitialized = now() /> | |
<!--- Return out. ---> | |
<cfreturn /> | |
</cffunction> | |
</cfcomponent> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfoutput> | |
<h1> | |
Application And Session Overview | |
</h1> | |
<p> | |
Application initialized: | |
#dateDiff( | |
"s", | |
application.dateInitialized, | |
now() | |
)# | |
seconds ago. | |
</p> | |
<p> | |
Session initialized: | |
#dateDiff( | |
"s", | |
session.dateInitialized, | |
now() | |
)# | |
seconds ago. | |
</p> | |
</cfoutput> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment