home *** CD-ROM | disk | FTP | other *** search
- <!--- This is a view-only example to illustrate CFAPPLICATION --->
- <!-------------------------------------------------------------
- This example shows how CFLOCK can be used to guarantee the
- consistency of data updates to variables in the Application,
- Server, and Session scopes if session management is
- turned on with the CFAPPLICATION tag in Application.cfm.
- You should copy the following code into an Application.cfm
- file in the wwwroot directory. Take out the comments
- around the code to enable it.
- --------------------------------------------------------------->
- <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 that will be
- 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#
- <CFIF #application.number# NEQ 1>
- turtlenecks
- <CFELSE>
- turtleneck
- </CFIF>
- to date.
- </CFOUTPUT>
- </CFLOCK>
- ------------------------------------------------------------------->
- <!--- End of Application.cfm --->