I am trying to persist session variables from one page to the next.
 
This is the application.cfm file:
 
<cfapplication name="game001"
  clientmanagement="Yes"
  sessionmanagement="Yes"
  sessiontimeout="#CreateTimeSpan(0,0,10,0)#"
  applicationtimeout="#CreateTimeSpan(0,0,10,0)#">
This is a template that runs at the beginning of each page (six pages - one for each formResult structure) to instatiate empty structure objects in the session scope:
 
<cfif  isDefined("session.formResult") IS FALSE>
 
 <!--- lock the session variable to stop race conditions --->
 <cflock name="game#SESSION.SessionID#"
  type="exclusive"
  timeout="3">
  
  <!--- instantite empty structures for each section --->
  <cfset session.formResult = StructNew()>  
  <cfset session.formResult.planning = StructNew()>
  <cfset session.formResult.buying = StructNew()>
  <cfset session.formResult.preparing = StructNew()>
  <cfset session.formResult.marketing = StructNew()>
  <cfset session.formResult.tenants = StructNew()>
  <cfset session.formResult.selling = StructNew()>
  
 </cflock>
</cfif>
 
This is a template that runs after every form submission ("type" is a hidden field in the form and has a value of one of the above structures, e.g., planning, buying, preparing, etc) - it copies the form results to the appropriate structure
 
<cfif isDefined("FORM.type")>
 <cfset session.formResult["#FORM.type#"] = FORM>
</cfif>
 
After running this last template then I cfdump the session scope. Each time it shows the form elements from the current form submission succesfully added to the appropriate structure in the session scope. But after submitting the next form then any form variables from the previous submission are not found - only the empty structure and the current variables each time
 
Anyone know why this is happening?
 
Thanks in advance,
 
Sam Westlake
 
 
 
 

Reply via email to