That's fixed it !! - Thanks Albert.
 
So why does this work?
 
Sam


From: Albert Popkov [mailto:[EMAIL PROTECTED]
Sent: 13 April 2004 15:55
To: [EMAIL PROTECTED]
Subject: RE: [ cf-dev ] Session Variables

you can try
<cfset session.formResult["#FORM.type#"] = Duplicate(FORM)>
 
this will actually create a new variable (without duplicate it should only create a reference to the same structure,
which is changed when the next form is submitted).
 
StructCopy may also be useful. There were some bugs reported with both Duplicate and StructCopy - such as
some problems working with nested structures - the best is to check macromedia.com for fixes etc.
 
 


From: Sam Westlake [mailto:[EMAIL PROTECTED]
Sent: 13 April 2004 14:05
To: [EMAIL PROTECTED]
Subject: [ cf-dev ] Session Variables

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