Application and Session Variables

In ColdFusion, you use variables to work around the Web's inherent statelessness. Session and application variables are persistent variable "scopes." You access these variables by prefacing the variable name with the scope name, for example: Session.MyVariable or Application.MyVariable. And because they are persistent, you can pass values between pages with a minimum of effort.

Enabling application and session variables

Session and application variables are similar in operation to client variables. Like client variables, they are enabled with the CFAPPLICATION tag. However, unlike client variables, which are stored in the system registry, a data source, or a cookie, application and session variables are always stored in the ColdFusion server's memory. This method offers obvious performance advantages. In addition, you can set time-out values for these variables either with CFAPPLICATION, or by specifying time-outs in the ColdFusion Administrator. You can also simply disable application and session variables entirely.

For information on setting time-outs for variables, See Administering_Coldfusion_Server/contents.htmAdministering ColdFusion Server.

Differentiating client, session, and application variables

This table shows the relationships among client, session, and application variables.:

Kinds of Variables 
Variable Type Application Names Client IDs Client Mgmt Session Mgmt Time-out
Client Optional Required Required n/a Optional
Session Optional Required Required Required Optional
Application Required n/a n/a n/a Optional

Note ColdFusion does not attempt to automatically evaluate application and session variables. You must use variable prefixes with these variables, as in Session.variablename or Application.variablename.