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>

View comments in LiveDocs