User Guide

Examples of cflock 239
</cfif>
</cflock>
<!--- Always display the number of turtlenecks sold --->
<cflock scope="Application"
timeout="10"
type ="ReadOnly">
<cfoutput>
E-Turtleneck is proud to say that we have sold
#application.number# turtlenecks to date.
</cfoutput>
</cflock>
The remaining sample code could appear inside the application page where
customers place orders.
In this simple example, the Application.cfm page displays the Application.number
variable value. Because Application.cfm is processed before any code on each CFML
page, the number that displays after you click the submit button does not include the
new order. One way you can resolve this problem is by using the OnRequestEnd.cfm
page to display the value at the bottom of each page in the application.
<html>
<head>
<title>cflock Example</title>
</head>
<body>
<h3>cflock Example</h3>
<cfif isdefined("form.submit")>
<!--- Lock Session variables --->
<!--- Note that we use the automatically generated Session
ID as the order number --->
<cflock scope="Session"
timeout="10" 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="10"
type="Exclusive">
<cfparam name=session.size default=#form.size#>
<cfparam name=session.color default=#form.color#>
</cflock>