202
<CFOUTPUT>
E-Turtleneck is proud to say that we have sold
#application.number# turtlenecks to date.
</CFOUTPUT>
</CFLOCK>
Tip
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.number + 1>
</CFLOCK>
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.
Developing Web Applications with ColdFusion
Need help?
Do you have a question about the COLDFUSION 4.5-DEVELOPING WEB and is the answer not in the manual?