firstly, for locking session variables, don't used a named lock; instead specify scope="Session".  also, you're making a reference to the session variable before you've locked it.  all session variable references should be locked, even if you're just reading a value.

secondly, your timeout value seems slightly short - 10 minutes.  could it be that it's taking you > 10 minutes in between submitting the different forms?  If so, the session will no longer exist when you come to submit the next form, and it'll start again with a new session.

thirdly, how about trying to use a different session variable structure for each form, instead of one structure to store all the sub-structures in.  there's little advantage in doing this, but it might give you a better idea of where the problem really lies.  
i.e.
  <cfset session.formResultplanning  = StructNew()>  
 <cfset session.formResultbuying  = StructNew()>
etc



Duncan Cumming
IT Manager

http://www.alienationdesign.co.uk
mailto:[EMAIL PROTECTED]
Tel: 0141 575 9700
Fax: 0141 575 9600

Creative solutions in a technical world

----------------------------------------------------------------------
Get your domain names online from:
http://www.alienationdomains.co.uk
Reseller options available!
----------------------------------------------------------------------
----------------------------------------------------------------------



"Sam Westlake" <[EMAIL PROTECTED]>

13/04/2004 14:04
Please respond to dev

       
        To:        <[EMAIL PROTECTED]>
        cc:        
        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