I am trying to set session variables for a list of varialbes and get the following error. I tried a number of things but it keeps balking at a period in the variable name. A CFML variable name cannot end with a "." character. The variable session. ends with a "." character. You must supply an additional structure key or delete the "." character. The CFML compiler was processing: * a cfset tag beginning on line 21, column 18. * a cfset tag beginning on line 21, column 18. The error occurred in C:\CFusionMX7\wwwroot\tools\b-b\qry_b-b.cfm: line 21 19 : <cfoutput> 20 : <cfloop query="bb_log"> 21 : <cfset thisfield = session.#field#> 22 : <cfset #thisfield# = #newval#><br> 23 : </cfloop> The part I am not clear on is the "You must supply an additional structure key".
You will need to lock/unlock the variable correctly but this is the syntax I used to create dynamic session variables. <cfset id = 1> <cfset temp = SetVariable("Session.Stuff#id#", "Some Value");> retrieval is similar <cfset someVar = Evaluate("Session.Stuff#id#");>
Or you can use use array syntax <cfset thisfield = session[field]> ...or ... <cfset thisfield = session["someID#Id#"]> 1) Generally you should avoid evaluate() when possible 2) You don't need pound signs here: <cfset #thisfield# = #newval#> It won't break anything, but its not needed. Instead use: <cfset thisfield = newval>
Agreed with STarlight. That method is the best, and most organizing method. When setting dynamic variables, always use brackets around it rather then periods (this goes with any structure, array, or list).