View comments | RSS feed
Contents > CFML Reference > ColdFusion Tags > cfapplication PreviousNext

cfapplication

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.

Application framework tags

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

cfassociate, cferror, cflock, cfmodule

ColdFusion MX 6.1: Added loginStorage attribute

ColdFusion MX:

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

loginStorage

Optional

cookie

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

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

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

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

Contents > CFML Reference > ColdFusion Tags > cfapplication PreviousNext

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

Version 6.1

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

Comments


jrunrandy said on Dec 29, 2003 at 1:30 PM :
See http://www.macromedia.com/support/coldfusion/ts/documents/hotfix_domain_cookies.htm for information on fixing a problem with cfapplication and domain cookies.
halL said on Feb 18, 2004 at 9:32 AM :
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
Sarge said on Mar 19, 2004 at 6:28 AM :
Add to the description for the Name attribute, the fact that there can only be 1 unnamed application. And that if there are more than 1, then they all share the same application scope.
Sarge said on Mar 19, 2004 at 6:32 AM :
Modify the scope locking text to indicate that with CFMX scope locking is only necessary to prevent race conditions. See http://www.macromedia.com/support/coldfusion/ts/documents/tn18235.htm.
Sarge said on Mar 19, 2004 at 6:32 AM :
We are working to improve the examples in the ColdFusion reference pages. We propose to replace the current example on this page with the the following example. If you have any comments on this example, add them to this page.

<!--- This example shows how to use cflock to prevent race conditions during 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 application and/or session variable storage. This tag is placed in a special file called Application.cfm that automatically runs before any other CF page in a directory (or subdirectory) where the Application.cfm file appears.</p>

<cfapplication name = "ETurtle"
sessionTimeout = #CreateTimeSpan(0, 0, 0, 60)#
sessionManagement = "Yes">

<!--- Initialize session and application variables used by E-Turtleneck. --->
<cfparam name="application.number" default="1">
<cfparam name="session.color" default= "">
<cfparam name="session.size" default="">

<cfif IsDefined("session.numPurchased") AND IsNumeric(trim(session.cartTotal))>
<!--- Use the application scope for the application variable to prevent race condition. This variablekeeps track of total number of turtlenecks sold. --->
<cflock scope = "Application" timeout = "30" type = "Exclusive">
<cfset application.number = application.number + session.numPurchased>
</cflock>
</cfif>

<cfoutput>
E-Turtleneck is proud to say that we have sold #application.number# turtlenecks to date.
</cfoutput>
<!--- End of Application.cfm --->
etnevels1 said on Sep 7, 2004 at 6:49 AM :
There are 2 question raised by this revised example:
1. does cfparam provide its own application scope and session scope locking?
2. by not using a cflock on the cfoutput, is it possible the output will be incorrect?
BlueSpline said on Oct 7, 2004 at 6:08 AM :
Is an event triggered when a session times out that can be trapped to allow CF to tidy up after the user?
jrunrandy said on Oct 7, 2004 at 6:42 AM :
On the Enterprise edition, you can do this through the Servlet API. CFDJ has an article on this, "Making the Most of J2EE Event Listeners" in the May 2004 Issue of CFDJ:
http://www.sys-con.com/magazine/?issueid=490&src=false

You may need a password to get past the link..
thejuggler said on Mar 14, 2005 at 1:59 PM :
Undocumented behavior change. The 'Name' attribute no longer accepts non alpha numeric characters. It's essential to be aware of this if you use UUID's as your application names.
yogesh mishra said on Jul 11, 2005 at 6:46 AM :
If ColdFusion is running on a cluster, you must specify clientStorage = "cookie" or a data source name; you cannot specify "registry".

Is it really possible that clientStorage can be specified as "cookie" when Coldfusion is running on a cluster?
Chris.Velevitch said on Jul 14, 2005 at 10:04 PM :
Can we have a more detailed explanation of application timeout? Do all variables get timed out or only the oldest varaibles? How are variables aged? If the server has been running for 10 days and applications have a 20 minute timeout, do timeouts oocur every 20 minutes even though no variables have been created? That's say I have set my timeout to 20 minutes. If I add a variable to the application scope and 19 minutes later change it value, does this variable disappear 1 minute later?
Chris.Velevitch said on Jul 14, 2005 at 10:58 PM :
What is the impact of reducing the application timeout on existing variables in the application scope?

 

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

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-pa3.htm