User Guide

Table Of Contents
Configuring and using application variables 357
Clearing the Session scope does not clear the session ID, and future requests from the browser
continue to use the same session ID until the browser exits. It also does not log the user out,
even if you use Session scope storage for login information. Always use the
cflogout tag to log
users out.
If you use J2EE session management, you can invalidate the session, as follows:
<cfset getPageContext().getSession().invalidate()>
This line creates a pointer to the servlet page context and calls an internal method to reset the
session. This clears all session information, including the session ID Session scope variables,
and if you are using session login storage, the login information, for future request. However,
the session information does remain available until the end of the current request. After you
invalidate a session, attempts by the browser to access the application will generate an invalid
session exception until the session times out.
Note: You cannot destroy the session and create a session on the same request, as creating a new
session involves sending session cookies back.
If you do not use client cookies, the Session scope and login state is available to your
application only as long as you pass the sessions CFID, CFTOKEN, and, for J2EE sessions,
jsessionid values in the URL query string. After you stop using these values, however, the
session data remains in memory until the session time-out period elapses.
Configuring and using application variables
Application variables are available to all pages within an application, that is, pages that have the
same application name. Because application variables are persistent, you easily can pass values
between pages. You can use application variables for information including the application name,
background color, data source names, or contact information.
You set the application name in the
cfapplication tag, normally on your applications
Application.cfm page. The application name is stored in the
Application.applicationName
variable.
Unlike client and session variables, application variables do not require that a client name (client
ID) be associated with them. They are available to any clients that use pages in the application.
Caution: Put code that uses application variables inside cflock tags in circumstances that might
result in race conditions from multiple accesses to the same variable. For information on using
cflock
tags, see “Locking code with cflock” on page 360.
The following sections describe how to configure and use application variables.