On 6/12/02, [EMAIL PROTECTED] penned:
>You're kidding me?  How come you never see things like this in help files,
>etc?  So, you're saying that if I do this:
>
><cfset variables.user = session.user>
>
><cfset variables.user.username = "blah blah, overwriting original value">
>
>That session.user.username now contains what I did for 
>variables.user.username?
>
>~Todd

No, that's not correct. variables.user.username will be "blah blah, 
overwriting original value". session.user will still be the original 
value.

If session.user is a simple value, a string, "Joe Blow", then using...

<cflock scope="session" type="readonly" timeout="10">
<cfset variables.user = session.user>
</cflock>
<cfoutput>#variables.user#</cfoutput>

..will be fine without locking the output because variables.user is 
a new variable.

However, if session.user is a "complex" variable, a query, array, 
etc., then using...

<cflock scope="session" type="readonly" timeout="10">
<cfset variables.user = session.user>
</cflock>
<cfoutput query="variables.user">#variables.user.username#<br></cfoutput>

..will need to be locked because you haven't created a new variable. 
You have simply created a "pointer" to session.user.

This will create a "new" variable called variables.user rather than a pointer:

<cflock scope="session" type="readonly" timeout="10">
<cfset variables.user = duplicate(session.user)>
</cflock>
<cfoutput query="variables.user">#variables.user.username#<br></cfoutput>

or for version 4.01...

<cflock name="some_unique_name" type="readonly" timeout="10">
<cfwddx action="cfml2wddx" input="#session.user#" output="newvariable">
<cfwddx action="wddx2cfml" input="#newvariable#" output="variables.user">
</cflock>
<cfoutput query="variables.user">#variables.user.username#<br></cfoutput>

Simple, yes? LOL
-- 

Bud Schneehagen - Tropical Web Creations

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
ColdFusion Solutions / eCommerce Development
[EMAIL PROTECTED]
http://www.twcreations.com/
954.721.3452
______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to