User Guide
224 Chapter 12 Using the Application Framework
Consider these additional limitations before implementing cookie storage for Client
variables:
• Many browsers allow only 20 cookies from a particular host to be set. ColdFusion
uses two of these cookies for CFID and CFToken and also creates a cookie named
cfglobals to hold global data about the client, such as HitCount, TimeCreated,
and
LastVisit. This limits you to 17 unique applications per host.
• Some browsers set a size limit of 4K bytes per cookie. ColdFusion encodes
nonalphanumeric data in cookies with a URL encoding scheme that expands at a
3-1 ratio, which means you should not store large amounts of data per client.
ColdFusion throws an error if you try to store more than 4000 encoded bytes of
data for a client.
Specifying Client variable storage in Application.cfm
The following example shows how to enable Client variable management using a
sample database called mydatasource.
To specify the Client variable storage method:
1 Open the file Application.cfm in ColdFusion Studio and modify it so that it
appears as follows:
<!--- This example illustrates cfapplication --->
<!--- Name the application and enable client management--->
<cfapplication NAME="SearchApp"
clientmanagement="Yes"
clientstorage="mydatasource">
2 Save the file as Application.cfm in the root directory of your application
framework.
Note
Client storage mechanisms are exclusive; when one storage type is in use, the values
set in other storage options are unavailable.
Using Client variables
When you enable Client variables for an application, you can use them to keep track
of long-term information that is associated with a particular client.
Creating a Client variable
To create a Client variable and set the value of the parameter, use the cfset or
cfparam tag; for example:
<cfset Client.FavoriteColor="Red">
After you set a Client variable in this manner, it is available for use within any page in
your application that is accessed by the client for whom the variable is set.