# Setting up client state management options

If you want to enable client state management, you must do so on every page in an application. Because the `Application.cfm` file is included in all of the application's pages, you enable client management in the CFAPPLICATION tag, at the beginning of `Application.cfm`.

| To enable client state management:

1. Open the file `Application.cfm` in 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">

2. Save the file as `Application.cfm` in the root directory of your application framework.

## Choosing a client variable storage method

Once you have enabled client state management, you then have to determine where you want to store client variables. The system-wide default is for client variables to be stored in the system registry. But your site administrator can choose to store them instead in a SQL database or in cookies.

There are two steps to change client variable storage: first, setting a client variable storage option in the Variables page of the ColdFusion Administrator, and then, noting the client variable storage location in the CFAPPLICATION tag. See Administering ColdFusion Server < >for information on using the ColdFusion Administrator.

You use the CLIENTSTORAGE attribute in the CFAPPLICATION tag to specify where you want to store client variables, providing one of three values:

- `Registry`
- The name of a configured client store
- `Cookie`

If no ClientStorage setting is specified, the default location, as noted in the ColdFusion Administrator Variables page, is used.

The following example shows how you enable client state management using a sample database called mydatasource.

| To note the client variable storage method:

1. Open the file `Application.cfm` in 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.

### Cookie storage

When you set `CLIENTSTORAGE="Cookie"` the cookie that ColdFusion creates has the application's name. Storing client data in a cookie is scalable to large numbers of clients, but this storage mechanism has some limitations. Chief among them is that if the client turns off cookies in the browser, client variables won't work.

Consider these additional limitations before implementing cookie storage for client variables:

- Netscape Navigator allows 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.
- Netscape Navigator sets a size limit of 4K bytes per cookie. ColdFusion encodes non-alphanumeric 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 will throw an error if you try to store more than 4000 encoded bytes of data for a client.