Chapter 12: Using the Application Framework
The following sample code might be part of the
<HTML>
<HEAD>
<TITLE>Define Session and Application Variables</TITLE>
</HEAD>
<H3>CFAPPLICATION Example</H3>
<P>CFAPPLICATION defines scoping for a
ColdFusion applicationand enables or disables
the storing of client and/or session variables.
This tag is placed in the Application.cfm file
for the current application.
<CFAPPLICATION NAME="ETurtle"
SESSIONTIMEOUT=CreateTimeSpan("60")
SESSIONMANAGEMENT="yes">
<!--- Initialize the session and application
variables that will be used by E-Turtleneck. Use
the session lock for the session variables.
The member variable sessionID creates the
session name for you. --->
<CFLOCK SCOPE="Session"
TIMEOUT="30" TYPE ="Exclusive">
<CFIF NOT IsDefined("session.size")>
</CFIF>
<CFIF NOT IsDefined("session.color")>
</CFIF>
</CFLOCK>
<!--- Use the application lock for the
application variable. This variable keeps
track of the total number of turtlenecks sold.
The application lock should have the same name
as specified in the CFAPPLICATION tag. --->
<CFLOCK Scope="Application"
TIMEOUT="30"
TYPE="Exclusive">
<CFIF NOT IsDefined("application.number")>
</CFIF>
</CFLOCK>
<CFLOCK SCOPE="Application"
TIMEOUT="30"
TYPE ="ReadOnly">
<CFSET session.size = "">
<CFSET session.color = "">
<CFSET application.number = 1>
file.
Application.cfm
201
Need help?
Do you have a question about the COLDFUSION 4.5-DEVELOPING WEB and is the answer not in the manual?