O'Reilly logo

Programming ColdFusion by Rob Brooks-Bilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Persistent Variables

As I mentioned in the introduction, the Web is a stateless environment. ColdFusion addresses this problem by providing five variable scopes you can use to maintain state within your application: application, client, cookie, session, and server. These are known as persistent variable scopes because the variables you set within them persist from template to template, in spite of the stateless nature of the Web. This allows you to build applications that can share data across multiple templates without having to pass the values via form fields or URL variables.

Here’s an overview of the types of persistent variables you can use in your ColdFusion applications:

Application

Application variables define application-wide settings for your application, such as data-source names and other constants. Application variables are stored in the server’s RAM and are most often defined in the Application.cfm template. Application variables are available to all users accessing the named application and are often referred to as global variables. Application variables must always be referenced using the Application prefix, as in Application. variable_name. By default, a single predefined application variable is available:

Application.ApplicationName

Application.ApplicationName returns the name of the application as defined in the NAME attribute of the CFAPPLICATION tag.

Client

Client variables store values associated with a particular user across multiple sessions. An ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required