MACROMEDIA COLDFUSION MX 61-CFML Reference page 224

Cfml reference
Hide thumbs Also See for COLDFUSION MX 61-CFML:
Table of Contents

Advertisement

<!--- Copy the following code into an Application.cfm file in the application
root
directory. --->
<!----------------
<!--- cfapplication defines scoping for a ColdFusion application and
enables or disables storing of application and session variables.
Put this tag in a special file called Application.cfm.
It is run before any other CF page in its directory. --->
<!--- Enable session management for this application --->
<cfapplication name = "ETurtle"
sessionTimeout = #CreateTimeSpan(0,0, 0, 60)#
sessionManagement = "Yes">
<!--- Initialize session and application variables used by E-Turtleneck.
Use 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 an application lock for the application-wide variable that
keeps track of the number of turtlenecks sold.
For a more efficient, but more complex, way of handling Application scope
locking, see "Developing ColdFusion MX Applications". --->
<cflock scope = "Application" timeout = "30" type = "Exclusive">
<cfif NOT IsDefined("application.number")>
<cfset application.number = 0>
</cfif>
</cflock>
<!----------------------- End of Application.cfm ----------------------->
<h3>cflock Example</h3>
<cfif IsDefined("form.submit")>
<!--- The form has been submitted, process the request --->
<cfoutput>
Thanks for shopping E-Turtleneck. You chose size <b>#form.size#</b>,
color <b>#form.color#</b>.<br><br>
</cfoutput>
<!--- Lock the code that assigns values to session variables. ---->
<cflock scope = "Session" timeout = "30" type = "Exclusive">
<cfparam name = session.size Default = #form.size#>
<cfparam name = session.color Default = #form.color#>
</cflock>
<!---- Lock the code that updates the Application scope number of
turtlenecks sold. --->
<cflock scope = "Application" timeout = "30" type = "Exclusive">
<cfset application.number = application.number + 1>
<cfoutput>
E-Turtleneck has now sold #application.number# turtlenecks!
</cfoutput>
</cflock>
224
Chapter 2: ColdFusion Tags
beginning of Application.cfm code
--------------->

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents