CFAPPLICATION |
Description
Defines the scope of a ColdFusion application; enables and disables storage of Client variables; specifies the Client variable storage mechanism; enables Session variables; and sets Application variable timeouts.
Category
Application framework tags

Syntax

    <cfapplication
       name = "application_name"
       loginStorage = "cookie" or "session"
       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">

See also
cfassociate, cferror, cflock, cfmodule
History
ColdFusion MX 6.1: Added loginStorage attribute

ColdFusion MX:

- Changed how persistent scopes are available: Server, Session, and Application scope variables are stored in memory as structures. In earlier releases, only Session and Application scope variables were stored this way. You cannot access the UDF function scope as a structure.
- Changed the algorithm for setting the CFTOKEN variable value: if the registry key UUIDToken is a non-zero value, ColdFusion uses a number constructed from the UUID plus a random number. Otherwise, ColdFusion sets the CFTOKEN variable default value using a positive random integer. (In earlier releases, ColdFusion always used a number constructed from the UUID plus a random number.)

Usage
This tag is typically used in the Application.cfm file, to set defaults for a ColdFusion application.
This tag enables application variables, unless they are disabled in the ColdFusion Administrator. The Administrator setting also overrides the sessionManagement attribute. For more information, see Configuring and Administering ColdFusion MX.
Server, application, and session variables

When you display, set, or update variables in the server, application, and session scopes, use the cflock tag with the scope attribute set to the following value:

- For server variables, specify "server"
- For application variables, specify "application"
- For session variables, specify "session"

For information about locking scopes, see cflock.
If ColdFusion is running on a cluster, you must specify clientStorage = "cookie" or a data source name; you cannot specify "registry".

If you use this tag to activate the Application and Client scopes, ColdFusion saves the application name as a key, whose maximum length is 64 characters. If an application name is longer than this, the client store fails during database processing.

Note: | The CFTOKEN variable is 8 bytes in length. Its range is 10000000 -99999999. If you specify ClientStorage=cookie, any Client scope variables set following a cfflush tag are not saved in the Client browser.

Example

    <!--- This example shows how to use cflock to guarantee consistent data
    updates to variables in Application, Server, and Session scopes. --->
       <h3>cfapplication Example</h3>
       <p>cfapplication defines scoping for a ColdFusion application and
    enables or disables the storing of application and/or sessionvariables.
    This tag is placed in a special file calledApplication.cfm that is run
    before any other CF page in a directory where the Application.cfm file
    appears.

       <cfapplication name = "ETurtle"
          sessionTimeout = #CreateTimeSpan(0, 0, 0, 60)#
          sessionManagement = "Yes">
       <!---    Initialize session and application variables used by E-Turtleneck.
    Use session scope for 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 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 --->

NAME |
| See Description
| For Application and Session variables: Required.
| For Client variables: Optional
Name of application. Up to 64 characters.

LOGINSTORAGE |
| Optional

Default value: "cookie"

- cookie: store login information in the Cookie scope
- session: store login information in the Session scope

CLIENTMANAGEMENT |
| Optional

Default value: "No"

- Yes: enables client variables
- No

CLIENTSTORAGE |
| Optional

Default value: "registry"

How client variables are stored:

- datasource_name: in ODBC or native data source. You must create storage repository in the Administrator.
- registry: in the system registry.
- cookie: on client computer in a cookie. Scalable. If client disables cookies in the browser, client variables do not work.

SETCLIENTCOOKIES |
| Optional

Default value: "Yes"

- Yes: enables client cookies
- No: ColdFusion does not automatically send CFID and CFTOKEN cookies to client browser; you must manually code CFID and CFTOKEN on the URL for every page that uses Session or Client variables.

SESSIONMANAGEMENT |
| Optional

Default value: "No"

- Yes: enables session variables
- No

SESSIONTIMEOUT |
| Optional
Default value: "Specified in Variables page of ColdFusion Administrator" Lifespan of session variables. CreateTimeSpan function and values in days, hours, minutes, and seconds, separated by commas.

APPLICATIONTIMEOUT |
| Optional
Default value: "Specified in Variables page of ColdFusion Administrator" Lifespan of application variables. CreateTimeSpan function and values in days, hours, minutes, and seconds, separated by commas.

SETDOMAINCOOKIES |
| Optional

Default value: "No"

- Yes: Sets CFID and CFTOKEN cookies for a domain (not a host). Required, for applications running on clusters.
- No