Contents > Developing ColdFusion MX Applications > Using Persistent Data and Locking > Configuring and using session variables > Accessing and changing session variables PreviousNext

Accessing and changing session variables

You use the same syntax to access a session variable as for other types of variables. However, you must lock any code that accesses or changes session variables.

For example, to display the number of items in a user's shopping cart, use favorite color that has been set for a specific user, for example, use the following code:

<cflock timeout=20 scope="Session" type="Exclusive">
   <cfoutput>
      Your shopping cart has #Session.ShoppingCartItems# items.
   </cfoutput>
</cflock>

To change increase the number of items in the shopping cart, use the following code:

<cflock timeout=20 scope="Session" type="Exclusive">
   <cfset Session.ShoppingCartItems = Session.ShoppingCartItems + 1>
</cflock>

Contents > Developing ColdFusion MX Applications > Using Persistent Data and Locking > Configuring and using session variables > Accessing and changing session variables PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.