when you say "This is a template that runs at the beginning of each page" - I assumed you meant this code was in your application.cfm, which is 'a template that runs at the beginning of each page'. Or are you actually calling a template seperately from the individual pages each time? If so, could you just transfer the code to application.cfm instead?
How about putting some output into the code that creates the session variables, so you can see each time it is called. Ideally, this If statement should only execute once - before (or after?) submitting the first form. Thereafter, the session variables should already exist, so it needn't be called again. Stick some output code in that if statement to see each time it is being executed though.
| "Sam Westlake" <[EMAIL PROTECTED]>
13/04/2004 14:51
|
To: <[EMAIL PROTECTED]> cc: Subject: RE: [ cf-dev ] Session Variables |
yep, cookies are turned on.
still getting the same problems though - I have debugged the template that instantiaites the structure collection and that is ONLY getting called the first time through.
Definately not a time-out problem.
I have changed the locking to "SESSION" and encapsulated all the code that accesses the SESSION scope in locks.
No improvements. I didn't put the sub-structures at the SESSION level (at the moment they all sit a structure in the Session scope), because I don't understand why this will help - but I'll try it next.
Will enabling J2ee Sessions help in anyway. I am new to sessions in CF.
Sam
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 13 April 2004 14:39
To: [EMAIL PROTECTED]
Subject: Re: [ cf-dev ] Session Variables
also, do you have session cookies enabled in your browser?
| "Sam Westlake" <[EMAIL PROTECTED]>
13/04/2004 14:04 | 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
