For each client that connects to a ShadoCMS site, a new session is created on the server. The contents of that session are available in request.userContext variable.
In order to write something to the a user's session, you can simply assign add to the request.userContext variable. ShadoCMS automatically takes care of everything else. For example:
<!--- Dump a user's userContext --->
<cfdump var="#request.userContext#">
<!--- Add a simple variable to a user's userContext --->
<cfset request.userContext.mySimpleVariable = "bob">
<!--- Add a structure to a user's userContext' --->
<cfset stUserAddress = structNew()>
<cfset stUserAddress.address1 = "Address 1 here">
<cfset stUserAddress.address2 = "Address 2 here">
<cfset stUserAddress.city = "City here">
<cfset request.userContext.address = stUserAddress>
Once a variable has been added to the userContext, it automatically becomes available for the user's session. So if a user navigates to another page, the variables setup on earlier pages would be available. For example, if a structure called address has been added to the request.userContext variable, it will be available as:
<cfdump var="#request.userContext.address#">
<cfoutput>#request.userContext.address.address1#</cfoutput>
Commonly used variables in request.userContext
- request.userContext.loggedin: Returns true or false depending on whether a user is logged in or not
- request.userContext.user_uuid: The UUID of the currently logged in user.
- request.userContext.state: Contains other details for the logged in user like email address, name etc.
- request.userContext.mode: Returns true or false dependent on the whether the user is previewing a page or editing a page
- request.userContext.language: Contains information about the current language the user is viewing the site in.
- request.userContext.setLanguage(): A function that be used to change languages programmtically.

