User Guide

Table Of Contents
339
CHAPTER 15
Using Persistent Data and Locking
Macromedia ColdFusion MX provides several variable scopes in which data persists past the life
of a single request. These are the Client, Application, Session, and Server scopes. These scopes let
you save data over time and share data between pages and even applications. (This chapter refers
to these scopes as persistent scopes.) In particular, you can use the Client and Session scopes to
maintain information about a user across multiple requests.
ColdFusion MX lets you lock access to sections of code to ensure that ColdFusion does not
attempt to run the code, or access the data that it uses, simultaneously or in an unpredictable
order. This locking feature is important for ensuring the consistency of all shared data, including
data in external sources in addition to data in persistent scopes.
This chapter describes how to use persistent scopes to develop an application and how to use
locking to ensure data consistency.
Contents
About persistent scope variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
Managing the client state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
Configuring and using client variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Configuring and using session variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Configuring and using application variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
Using server variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
Locking code with cflock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
Examples of cflock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368