When you use custom tags to place exclusive locks around the session scope, it causes ColdFusion service issues, which affects all users within a shared environment. You can prevent these ColdFusion service issues by using a common fix we use to fine tune our code:
Use a variable scope to remove the memory being used by the session scope once the tag has completed it's necessary action.
<cflock timeout="45" throwontimeout="Yes" type="READONLY" scope="SESSION">
<CFSET variables.LSess=Duplicate(session)>
</cflock> |
We would be replacing all references of session to variables.LSess and copying the local copy of the structure back to the session scope.
<cflock timeout="45" throwontimeout="Yes" type="EXCLUSIVE" scope="SESSION">
<CFSET session=Duplicate(variables.LSess)>
</cflock> |
If you have difficulty copying over structures in your local version to the session scope, you can duplicate each key under the local session structure over to the scope. Your final code would look similar to:
<cflock timeout="45" throwontimeout="Yes" type="EXCLUSIVE" scope="SESSION">
<CFLOOP index="Key" list=#StructKeyList(variables.LSess)#>
<CFSET "Session.#Key#"=Duplicate(Evaluate("variables.LSess.#Key#"))>
</CFLOOP>
</cflock> |