
314
DEVELOPING
COLDFUSION 9 APPLICATIONS
Developing CFML Applications
Las
t
upda
te
d 8/5/2010
Note:
ColdFusion lets you delete or change the values of the built-in session variables. As a general rule, avoid doing so.
If you enable client variables and ColdFusion session management, ColdFusion uses the same values for the Client and
Session scope
CFID
,
CFToken
, and
URLtoken
variables. ColdFusion gets the values for these variables from the same
source, the client’s
CFID
and
CFTOKEN
cookies.
If you use J2EE session management, the Session scope does not include the
Session.CFID
or
Session.CFToken
variables, but does include the
Session.URLToken
and
Session.SessionID
variables. In this case, the
Session.SessionID
is the J2EE session ID and
Session.URLToken
consists of the string
jsessionid=
followed by
the J2EE session ID.
Getting a list of session variables
Use the
StructKeyList
function to get a list of session variables, as follows:
<cflock timeout=20 scope="Session" type="Readonly">
<cfoutput> #StructKeyList(Session)# </cfoutput>
</cflock>
Important:
Always put code that accesses session variables inside
cflock
tags.
Creating and deleting session variables
Use a standard assignment statement to create a new session variable, as follows:
<cflock timeout=20 scope="Session" type="Exclusive">
<cfset Session.ShoppingCartItems = 0>
</cflock>
Use the
structdelete
tag to delete a session variable; for example:
<cflock timeout=20 scope="Session" type="Exclusive">
<cfset StructDelete(Session, "ShoppingCartItems")>
</cflock>
Note:
If you set session variables on a CFML template that uses the
cflocation
tag, ColdFusion might not set the
variables. For more information, see TechNote at
www.adobe.com/go/tn_18171
.
Accessing and changing session variables
You use the same syntax to access a session variable as for other types of variables. However, lock any code that accesses
or changes session variables.
Variable
Description
Session.CFID
ColdFusion session management only: the client ID, normally stored on the client system as a cookie.
Session.CFToken
ColdFusion session management only: the client security token, normally stored on the client system as a
cookie.
Session.URLToken
ColdFusion session management: A combination of the
CFID
and
CFToken
values in the form
CFID=
IDNum
&CFTOKEN=
tokenNum. Use this variable if the client does not support cookies and you must
pass the
CFID
and
CFToken
variables from page to page.
J2EE session management: A combination of the
CFID
and
CFToken
cookies and the J2EE session ID, in
the form
CFID=
IDNum
&CFTOKEN=
tokenNum
&jsessionid=
SessionID.
Session.SessionID
A unique identifier for the session.
ColdFusion session management: a combination of the application name and
CFID
and
CFToken
values.
J2EE session management: the
jsessionid
value.
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...