Storing Session Data In Session Variables - MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Develop Manual

Developing web applications with coldfusion
Table of Contents

Advertisement

Chapter 12: Using the Application Framework
period, ColdFusion interprets this as the end of the session and clears any variables
associated with that session.
The default time-out for session variables is set to 20 minutes. In the Variables page of
the ColdFusion Administrator, you can change this time-out value. See Administering
ColdFusion Server for more information.
You can also set the time-out period for session variables inside a specific application
(thereby overruling the Administrator default setting) by using the SESSIONTIMEOUT
attribute of the CFAPPLICATION tag.

Storing session data in session variables

Session variables are designed to store session-level data. They are a convenient place
to store information that all pages of your application might need during a user
session. Using session variables, an application could initialize itself with user-specific
data the first time a user hit a page of that application. This information could then
remain available while that user continues to use that application. For example,
information about a specific user's preferences could be retrieved from a database
once, the first time a user hits any page of an application. This information would
remain available throughout that user's session, thereby avoiding the overhead of
retrieving the preferences again and again.
Session variables work exactly as client variables do, in that they require a client name
(client ID) and are always scoped within that client ID. Session variables also work
within the scope of an application name if one is supplied, in which case their scope
will be the combination of the client ID and the application name.
To enable session variables, set
in your
Application.cfm
CFAPPLICATION tag, you must specify the application's name. Following is an
example of turning on session management:
<!--- This example illustrates CFAPPLICATION --->
<!--- Name the application, and turn on
session management --->
<CFAPPLICATION NAME="GetLeadApp" SESSIONMANAGEMENT="Yes">
<!--- set data source for this application --->
<CFSET dsn = "my_dsn">
<!--- set global error handling for this application --->
<CFERROR TYPE="REQUEST" TEMPLATE="request_err.cfm"
MAILTO="webmaster@mysite.com">
<CFERROR TYPE="VALIDATION" TEMPLATE="val_err.cfm"
MAILTO="webmaster@mysite.com">
<!--- set some global variables for this application
SESSIONMANAGEMENT="Yes"
file. Note that when you turn on session management in the
195
in the CFAPPLICATION tag

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 4.5

Table of Contents