Using Session Variables; Enabling Session Variables; What Is A Session - MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual

Table of Contents

Advertisement

228

Using Session Variables

Use Session variables when you need the variables for a single site visit or set of
requests. For example, you might use Session variables to store a user's selections in
a shopping cart application. (Use Client variables when you need the variable for
future visits.)
Caution
You must use the
variable simultaneously. Failure to do so can result in data corruption.

Enabling Session variables

You enable Session variables in the
To enable Session variables:
The following code is an example of turning on session management:
<!--- Name the application, and turn on Session management
<cfapplication name="GetLeadApp"

What is a session?

A session refers to all the connections that a single client might make to a server in
the course of viewing any pages associated with a given application. Sessions are
specific to individual users. As a result, every user has a separate session and has
access to a separate set of Session variables.
This logical view of a session begins with the first connection by a client and ends
(after a specified timeout period) after that client's last connection. However,
because of the stateless nature of the Web, it is not always possible to define a precise
point at which a session ends. In the real world, a session ends when the user finishes
using an application. In most cases, however, a Web application has no way of
knowing if a user is finished or just lingering over a page.
You can impose some structure on Session variable duration by specifying a timeout
period. If the user does not access a page of the application within this timeout
period, ColdFusion interprets this as the end of the session and clears any variables
associated with that session.
cflock
Set
sessionManagement="Yes"
Use the
attribute to specify the application's name.
name
Optionally, use the
sessionTimeout
session timeout value. Use the
of days, hours, minutes, and seconds for the timeout.
with a 45-minute timeout --->
sessionmanagement="Yes"
sessiontimeout=#CreateTimeSpan(0,0,45,0)#>
Chapter 12 Using the Application Framework
tag to prevent multiple requests from accessing any Session
cfapplication
attribute to set an application-specific
CreateTimeSpan
tag in your Application.cfm file.
function to specify the number

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 5

Table of Contents