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 the following code:
<cflock timeout=20 scope="Session" type="Exclusive"> <cfoutput> Your shopping cart has #Session.ShoppingCartItems# items. </cfoutput> </cflock>
To 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>