Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 318

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Developing CFML Applications
Selecting and enabling session variables in ColdFusion Administrator
To use session variables, they must be enabled on the ColdFusion Administrator Memory Variables page. (They are
enabled by default.) You can also use the Administrator Memory Variables page to do the following:
• Select to use ColdFusion session management (the default) or J2EE session management.
• Change the default session time-out. Application code can override this value. The default value for this time-out
is 20 mins.
• Specify a maximum session time-out. Application code cannot set a time-out greater than this value. The default
value for this time-out is two days.
Enabling session variables in your application
Enable session variables in the initialization code of your Application.cfc file or in the
Application.cfm file.
Do the following in the Application.cfc initialization code, below the
• Set This.sessionManagement="Yes".
• Set This.name to specify the name of the application.
• Optionally, set This.sessionTimeout to set an application-specific session time-out value. Use the
function to specify the number of days, hours, minutes, and seconds for the time-out.
Do the following in the Application.cfm file to enable session variables:
• Set
sessionManagement="Yes"
• Use the
attribute to specify the name of the application.
name
• Optionally, use the
sessionTimeout
function to specify the number of days, hours, minutes, and seconds for the time-out.
CreateTimeSpan
The following sample code enables session management for the GetLeadApp application and sets the session variables
to time out after a 45-minute period of inactivity:
<cfapplication name="GetLeadApp"
sessionmanagement="Yes"
sessiontimeout=#CreateTimeSpan(0,0,45,0)#>
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, such as shopping cart contents or score counters.
Using session variables, an application can initialize itself with user-specific data the first time a user accesses one of
the pages of the application. This information can remain available while that user continues to use that application.
For example, you can retrieve information about a specific user's preferences from a database once, the first time a user
accesses any page of an application. This information remains available throughout that user's session, thereby
avoiding the overhead of retrieving the preferences repeatedly.
Standard session variables
If you use ColdFusion session variables, the Session scope has four built-in, read-only variables that your application
can use. If you use J2EE session management, the Session scope has two built-in variables. Generally, you use these
variables in your ColdFusion pages only if your application supports browsers that do not allow cookies. For more
information on supporting browsers that do not allow cookies, see
on page 305. The following table describes the built-in session variables.
attribute to set an application-specific session time-out value. Use the
"Using client and session variables without
Last updated 1/20/2012
cfapplication
tag, to enable session variables:
cfcomponent
313
tag in your
CreateTimeSpan
cookies"

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents