202
Developing Web Applications with ColdFusion
<CFOUTPUT>
E-Turtleneck is proud to say that we have sold
#application.number# turtlenecks to date.
</CFOUTPUT>
</CFLOCK>
Tip
In general, you should limit lock scopes. When locking variables, queries,
and arrays (anything other than structures), you can copy to a local
variable in the CFLOCK block, then reference the local variable.
The remaining sample code would appear inside the application page where
customers place orders.
<HTML>
<HEAD>
<TITLE>CFLOCK Example</TITLE>
</HEAD>
<BODY>
<H3>CFLOCK Example</H3>
<CFIF IsDefined("form.submit")>
<!--- Lock session variables --->
<CFLOCK SCOPE="Session"
TIMEOUT="30" TYPE="ReadOnly">
<CFOUTPUT>Thank you for shopping E-Turtleneck.
Today you have chosen a turtleneck in size
<B>#form.size#</B> and in the color <B>#form.color#</B>.
Your order number is #session.sessionID#.
</CFOUTPUT>
</CFLOCK>
<!--- Lock session variables to assign form values to them.
To lock session variables, you should get the session ID
with the sessionID member variable. --->
<CFLOCK SCOPE="Session"
TIMEOUT="30"
TYPE="Exclusive">
<CFPARAM Name=session.size Default=#form.size#>
<CFPARAM Name=session.color Default=#form.color#>
</CFLOCK>
<!--- Lock application variable application.number to
find the total number of turtlenecks sold. If you don’t
know the name of the application, you can use the member
variable applicationName to find it.--->
<CFLOCK SCOPE="Application"
TIMEOUT="30" TYPE="Exclusive">
<CFSET application.number=application. 1>
</CFLOCK>
Summary of Contents for COLDFUSION 4.5-DEVELOPING WEB
Page 1: ...Allaire Corporation Developing Web Applications with ColdFusion ColdFusion 4 5...
Page 14: ...xiv Developing Web Applications with ColdFusion...
Page 26: ...xxvi Developing Web Applications with ColdFusion...
Page 34: ...8 Developing Web Applications with ColdFusion...
Page 70: ...44 Developing Web Applications with ColdFusion...
Page 84: ...58 Developing Web Applications with ColdFusion...
Page 114: ...88 Developing Web Applications with ColdFusion...
Page 148: ...122 Developing Web Applications with ColdFusion...
Page 174: ...148 Developing Web Applications with ColdFusion...
Page 208: ...182 Developing Web Applications with ColdFusion...
Page 244: ...218 Developing Web Applications with ColdFusion...
Page 274: ...248 Developing Web Applications with ColdFusion...
Page 288: ...262 Developing Web Applications with ColdFusion...
Page 300: ...274 Developing Web Applications with ColdFusion...
Page 350: ...324 Developing Web Applications with ColdFusion...
Page 362: ...336 Developing Web Applications with ColdFusion...