cfapplication

Description

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.

Category

Web 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, cfauthenticate, cferror, cflock, cfmodule

Attributes

Attribute
Description
name
The name of your application. This name can be up to 64 characters long.
Required for application and session variables, optional for client variables.
clientManagement
Optional. Yes or No. Enables client variables. Default is No.
clientStorage
Optional. Specifies how ColdFusion stores client variables:
  • datasourcename    Store client variables in the specified ODBC or native data source. To use this option, you must create a client variable storage repository using the Variables page of the ColdFusion Administrator.
  • registry    Store client variables in the system registry (default).
  • cookie    Store client variables on the client computer in a cookie. Storing client data in a cookie is scalable for large numbers of clients, but with this storage method, if the client turns off cookies in the browser, client variables do not work.
setClientCookies
Optional. Yes or No. Yes enables client cookies. Default is Yes.
If you set this attribute to "No", ColdFusion does not automatically send the CFID and CFTOKEN cookies to the client browser; you must manually code CFID and CFTOKEN on the URL for every page that uses Session or Client variables.
sessionManagement
Optional. Yes or No. Yes enables session variables. Default is No.
sessionTimeout
Optional. Enter the CreateTimeSpan function and values in days, hours, minutes, and seconds, separated by commas, to specify the lifespan of session variables. The default value is specified in the Variables page of the ColdFusion Administrator.
applicationTimeout
Optional. Enter the CreateTimeSpan function and values in days, hours, minutes, and seconds, separated by commas, to specify the lifespan of application variables. The default value is specified in the Variables page of the ColdFusion Administrator.
setDomainCookies
Optional. Yes or No. Sets the CFID and CFTOKEN cookies for a domain, not just a single host. Applications that are running on clusters must set this value to Yes. The default is No.

Usage

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.

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

Example

<!------------------------------------------------------------- 

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



Banner.Novgorod.Ru