Defines scoping for a ColdFusion application, enables or disables storing client variables, and specifies a client variable storage mechanism. By default, client variables are disabled. Also, enables session variables and sets timeouts for session and application variables. Session and application variables are stored in memory.
Web application framework tags
<cfapplication name = "application_name"
clientManagement = "Yes" or "No"
clientStorage = "datasource_name" or "Registry"
or "Cookie"
setClientCookies = "Yes" or "No"
sessionManagement = "Yes" or "No"
sessionTimeout = #CreateTimeSpan(days, hours,
minutes, seconds)#
applicationTimeout = #CreateTimeSpan(days, hours,
minutes, seconds)#
setDomainCookies = "Yes" or "No">
cfassociate, cfauthenticate, cferror, cflock, cfmodule
The cfapplication tag is typically used in the Application.cfm file to set defaults for a specific ColdFusion application.
The cfapplication tag enables application variables unless they are disabled in the ColdFusion Administrator. The ColdFusion Administrator setting also overrides the sessionManagement attribute. For more information, see Advanced ColdFusion Administration.
When you display, set, or update variables in the server, application, and session scopes, use the cflock tag with the scope attribute. For server variables, specify the "Server" scope. For application variables, specify the "Application" scope. For session variables, specify the "Session" scope. For information about locking server, application, and session scopes, see cflock.
If ColdFusion is running on a cluster, you must specify either Cookie or a data source name for clientStorage; you cannot specify Registry.
<!-------------------------------------------------------------
This example shows how cflock can be used to guarantee the
consistency of data updates to variables in the Application,
Server, and Session scopes.
Copy the following code into an Application.cfm
file in the snippets directory.
--------------------------------------------------------------->
<html>
<head>
<title>Define Session and Application Variables</title>
</head>
<BASEFONT face = "Arial, Helvetica" size = 2>
<body bgcolor = "#FFFFD5">
<H3>cfapplication Example</H3>
<P>cfapplication defines scoping for a ColdFusion application and
enables or disables the storing of application and/or session
variables. This tag is placed in a special file called
Application.cfm that is run before any other CF template in a
directory where the Application.cfm file appears.
<cfapplication name = "ETurtle"
sessionTimeout = #CreateTimeSpan(0, 0, 0, 60)#
sessionManagement = "Yes">
<!-------------------------------------------------------------
Initialize the session and application variables
used by E-Turtleneck. Use the session scope for the session
variables.
--------------------------------------------------------------->
<cflock scope = "Session" timeout = "30" type = "Exclusive">
<cfif NOT IsDefined("session.size")>
<cfset session.size = "">
</cfif>
<cfif NOT IsDefined("session.color")>
<cfset session.color = "">
</cfif>
</cflock>
<!----------------------------------------------------------------
Use the application scope for the application variable. This
variable keeps track of the total number of turtlenecks sold.
------------------------------------------------------------------->
<cflock scope = "Application" timeout = "30" type = "Exclusive">
<cfif NOT IsDefined("application.number")>
<cfset application.number = 1>
</cfif>
</cflock>
<cflock scope = "Application" timeout = "30" type = "readOnly">
<cfoutput>
E-Turtleneck is proud to say that we have sold
#application.number# turtlenecks to date.
</cfoutput>
</cflock>
<!--- End of Application.cfm --->