A session begins when a visiting client somehow identifies itself to the web server. The
web server assigns the client a unique session id, which the client uses to re-identify itself
as it moves from page to page on the website. Most of the time, these unique ids are stored
in session cookies that expire after the client hasn't interacted with the server for some
amount of time. The amount of time varies depending on the web application. For
example, an online investment site might have very short sessions, so that if a user leaves
her computer without logging out, another user who sits down at the same computer
several minutes later cannot continue with the first user's session.
The picture above shows the Memory Variables settings in ColdFusion Administrator,
where Session management is configured.
J2EE Session Variables
The first checkbox gives the option of using J2EE session variables instead of ColdFusion
session variables. The two major advantages of using J2EE session variables are:
- Sessions end when a user closes the browser. This is not the case with ColdFusion
- The Session scope is serializable, which allows session variables to be shared
across servers. Again, this is not the case with ColdFusion session variables.
There is really no downside to using J2EE session variables, so it is recommended that
you check this box.
Enabling Application Variables
The second checkbox gives the option to enable Application variables. Application
variables are shared between all users of the application and live until ColdFusion
Application Server is shut down, they are explicitly deleted, or the application times out
due to a setting in <cfapplication>.
Application variables are useful for storing data such as data source names and file paths
that are the same for all users over the life of the application, so it is recommended that
you check this box.
Enabling Session Variables
The third checkbox gives the option to enable Session variables. Session variables are
variables that are specific to a user's session (or visit) on the site. If session variables are
not enabled, it becomes very difficult to track a user throughout his visit, so it is
recommended that you check this box as well.
The <cfapplication> Tag
The <cfapplication> tag is used to:
- Define the name of a ColdFusion application.
- Enable or disable Client variables.
- Specify where Client variables are stored.
- Enable Session variables.
- Set Application variable timeouts.
||Name of application.
||Where to store login variables (in Cookies or
||Enable client variables. Default is "No".
||Where to store client variables.
||Enable cookies. Default is "Yes".
||Enable session management. Default is "No".
||Lifespan of session variables.
||Lifespan of application variables.
||Sets CFID and CFTOKEN for a domain.
The <cfapplication> tag is most often used at the top of the Application.cfm
file. A typical <cfapplication> tag looks like this:
If sessionTimeout and applicationTimeout are not
defined in the <cfapplication> tag, as in the tag above, the
default values set in ColdFusion Administrator are used.
Basics of Structures
A ColdFusion structure is a data type that can be used to hold collections of like data.
ColdFusion provides many functions to make it easy to work with and manipulate
structures. A few of these functions are described in the table below.
||Returns true if the specified variable is a structure.
||Creates a new structure.
||Removes all data from specified structure.
||Removes the specified item from the specified structure.
||Returns the value associated with the specified key in the
The example below creates a structure called person,
adds properties to the structure, deletes a property and then loops through a substructure.
The Session, Application, and Client scopes are all available as ColdFusion structures,
which means that they can be manipulated using the Structure functions.