Copy link to clipboard
Copied
Is there any way that i can assign a session variable a name from a variable?
Something like this but that actually works?
<cfset variables.userid = 238>
<cfset session.user#variables.userid# = 1>
Thanks,
Ben
<cfset session["user" & variables.userid] = 1>
Learn about array notation of ColdFusion variables, it is a powerful concept.
Copy link to clipboard
Copied
<cfset session["user" & variables.userid] = 1>
Learn about array notation of ColdFusion variables, it is a powerful concept.
Copy link to clipboard
Copied
<cfset session["user" & variables.userid] = 1>
Copy link to clipboard
Copied
To elaborate on Ian's comment ...
There are two main forms of "structured variables" provided by ColdFusion. (They are, of course, the "usual suspects" ...)
The underlying implementation in both cases is provided by Java, because ColdFusion performs "on-the-fly" compilation into Java, which is what actually gets executed by the engine.
All of the predefined system variables are either arrays or structs, or at least, functionally appear to be.
Copy link to clipboard
Copied
Thank you very much!