Managing Client Variables
ColdFusion includes a number of options designed to give you a great deal of flexibility in managing client variables. Client variables in ColdFusion give you the ability to determine the identity of a client visiting your site. Identifying clients and customizing page content for users requires the ability to manage client state.
Contents
-
About Client Variables 152
-
Enabling External Client State Management 153
About Client Variables
ColdFusion allows the following ways of managing client variables:
-
Using the system Registry to store client variables
-
Using browser cookies
-
Using an external data source of your choice
Planning client state management
The method you choose to store client variables will depend on a number of factors as described in the following table:
Client Variable Storage | ||
---|---|---|
Storage Type | Advantages |
Disadvantages |
System registry |
|
(Windows NT only) |
Browser cookies |
|
|
External repository |
|
|
Increasing maximum registry size (Windows NT)
Windows NT notifies you if your registry data is approaching the limit defined for registry size in the System Properties dialog. If you receive this message, you can open the System Properties dialog and increase the minimum size of your system registry.
To increase maximum registry size:
-
Open the System Control Panel and click the Performance tab.
-
In the Virtual Memory group box, click the Change button to open the
Virtual Memory dialog.
- At the bottom of the dialog, the current registry size is reported.
Specify a new maximum registry size in MB.
Enabling External Client State Management
You enable client state management in the ColdFusion Server using the Administrator to specify a data source repository where you want to store client variables.
Although you can select and use an existing data source to store client variables, Allaire recommends creating a new data source specifically for the purpose of storing client variables. By separating data sources, you can more easily define security options for the data sources used in your ColdFusion environment.
When creating a new data source for client variables, you do not need to create any tables in the data source. ColdFusion automatically creates the tables necessary to store client variables.
To create a client variable data source:
-
Open the ColdFusion Express Administrator to the Data Sources page.
-
Enter a data source name in the text entry box and click Add.
-
In the Create Data Source page, enter information about the new data
source location (path) as well as other options.
Excel and Text data sources do not appear as valid data sources for use in configuring an external client data source repository. Neither data source type supports the SQL required for the client variable repository.
- Click Create to create the new data source.
To enable your client variable data source:
-
Open the ColdFusion Administrator to the Variables page, which is in
the Server group.
-
Select the name of the data source you want to use for storing
client variables in the drop down list box, and click Add.
-
On the Create Client Variable Storage page, select the options you
want.
Client variable storage options
When you configure a data source for client variable storage, you have several options for configuring the data source:
-
Purging variables older than a specified number of days
-
Configuring global client variable updates
-
Automatically creating tables in the client variable data source
Purge client variables
Ordinarily, you don’t want to have client variables preserved indefinitely. ColdFusion allows you to set a limit to the length of time a client variable remains active. You can configure your client variable data source to expire client variables after some number of days you specify.
As an example of how this can be useful, take the case of an online store. A user adds items to his or her shopping basket, the details of which are stored as client variables in a ColdFusion data source, but never completes the transaction, instead, choosing to end the session. You want to be able to easily clear the contents of the shopping cart after some number of days. Enabling ColdFusion to purge clients can help keep your client variables data source from getting cluttered with data you don’t need.
Disable global client variable updates
By default ColdFusion updates client variables for every page request. Use this option if you don’t want ColdFusion to perform these updates. When updates are disabled, ColdFusion only updates global client variables when they are first created and when they are updated. Since updating global client variables for every page request requires a trip to the data source and back, disabling updates helps to improve the performance of your application pages.
Create client variable data source tables
Use this option to allow ColdFusion to create the tables necessary for client variables when you first configure the data source for this purpose. As you configure other servers in your cluster to use this client variables data source, be sure to disable the option for ColdFusion to create the necessary tables. If you inadvertently enable automatic table generation, ColdFusion generates a SQL error because it tries to create tables that already exist.
156 Developing Web Applications with ColdFusion Express
C HA PT ER 16