View comments | RSS feed

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"
  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

New in ColdFusion MX: 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.

New in ColdFusion MX: ColdFusion sets the CFTOKEN variable value using this algorithm: 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.)

Attributes

Attribute Req/Opt Default Description
name
See Description

Name of application. Up to 64 characters.
For Application and Session variables: Required.
For Client variables: Optional
clientManagement
Optional
No
  • Yes: enables client variables
  • No
clientStorage
Optional
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
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
No
  • Yes: enables session variables
  • No
sessionTimeout
Optional
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
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
No
  • Yes: Sets CFID and CFTOKEN cookies for a domain (not a host). Required, for applications running on clusters.
  • No

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 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 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.

The CFTOKEN variable is 8 bytes in length. Its range is 10000000 -99999999.

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 --->

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6

Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.

Comments


No screen name said on Feb 17, 2004 at 1:04 PM :
getting ready for CFMX exam i came across a question presented in CFMX ema buster :True or false: The NAME attribute of the <CFAPPLICATION> tag must be set in
order to use applicaiton variables. i woudl assume from macromedia livedocs that the answer is TRUE however Centrasoft said the answer is FALSE and here is their argument:"the MM docs are incorrect. In fact, elsewhere in the docs it (correctly) states that NAME attribute is indeed optional, because you can have ONE unnamed application per server so that CFMX can share variables
with a J2EE server."
So please help. WHAT is the correct answer?
halL said on Feb 18, 2004 at 9:30 AM :
You are correct. ColdFusion MX does not require an Application name to use Application scope variables.
However, there can only be one unnamed Application on a ColdFusion J2EE application.
For more information see http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/java18.htm
(This is the ColdFusion MX 6.1 version of the documentation, but I beileve it also applies to ColdFusion MX.)

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/Tags-pt14.htm