I really hope you can help me. I usually read my session variables into a local variable, so that I don't have to create endless read locks. But I came across some interesting behavior. Note that I have not applied any write locks for brevity's sake:
Consider the following:
EXAMPLE 1:
<cfset session.testvalue = 1 /> <cfset lcktestvalue = session.testvalue /> <cfoutput>#lcktestvalue#</cfoutput><br /> <cfset session.testvalue = 2 /> <cfoutput>#lcktestvalue#</cfoutput> OUTPUT:
1
1
EXAMPLE 2:
<cfset session.testvalue1.item = 1 /> <cfset lcktestvalue1 = session.testvalue1 /> <cfoutput>#lcktestvalue1.item#</cfoutput><br /> <cfset session.testvalue1.item = 2 /> <cfoutput>#lcktestvalue1.item#</cfoutput> OUTPUT:
1
2
I am trying to work out why the second example, updates the 'lcktestvalue1.item', when the value was only read once? I would have expected example 1 & 2 to produce the same output, and the following to produce the second example's output:
EXAMPLE 3:
<cfset session.testvalue1.item = 1 /> <cfset lcktestvalue1 = session.testvalue1 /> <cfoutput>#lcktestvalue1.item#</cfoutput><br /> <cfset session.testvalue1.item = 2 /> <cfset lcktestvalue1 = session.testvalue1 /> <cfoutput>#lcktestvalue1.item#</cfoutput> OUTPUT:
1
2
The only reason for this behavior, I can think of, is that the second example, uses a structure inside a structure. But,I cannot expand on this concept. Can you? I really need to understand this, because I am creating a shopping cart, which makes extensive use of the methodology in example 2. It actually works fine, but I am not sure why, and I am afraid under load, it may fail?
Thank you for any help you can give me on this.