Well, it's true...crude. =P

<cfscript>
tempCrap = structNew();
tempCrap.test1 = "blahblahblahblah";
tempCrap.test2 = "blahblahblahblah";
</cfscript>

<cflock timeout="60" throwontimeout="No" type="EXCLUSIVE" scope="SESSION">
        <cfset session.stuff = tempCrap>
        <cfdump var="#session.stuff#">
</cflock>
<hr>
<cflock timeout="60" throwontimeout="No" type="READONLY" scope="SESSION">
        <cfset variables.sayitaintso = session.stuff>
</cflock>

<cfset variables.sayitaintso.test1 = "BLARGH!">
<cfset variables.sayitaintso.test3 = "GROWL!">

<cflock timeout="60" throwontimeout="No" type="READONLY" scope="SESSION">
        <cfdump var="#session.stuff#">
</cflock>


Luckily, I don't do this too much.  Raymond is right, make sure you use 
the duplicate() function.  I wish I'd known that earlier, I was totally 
oblivious to it... that's 2 things I've learned from Raymond! :)

~Todd

---------- Forwarded message ----------
Date: Wed, 12 Jun 2002 09:33:49 -0400 (EDT)
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: re: Absolutly neccesary to cflock session variables


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


On Wed, 12 Jun 2002, Raymond Camden wrote:

> Just be careful with this code:
> 
> <cfset variables.user = session.user>
> 
> If session.user is a structure then you are creating a pointer, not a
> copy. You would need to use this instead:
> 
> <cfset variables.user = duplicate(session.user)>
> 
> =======================================================================
> Raymond Camden, ColdFusion Jedi Master for Macromedia
> 
> Email    : [EMAIL PROTECTED]
> Yahoo IM : morpheus
> 
> "My ally is the Force, and a powerful ally it is." - Yoda 
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
> > Sent: Wednesday, June 12, 2002 8:56 AM
> > To: CF-Talk
> > Subject: Re: Absolutly neccesary to cflock session variables
> > 
> > 
> > If the session is locked prior to calling 
> > isdefined('session.myvariable') 
> > it should throw an error.  Anytime I have a session variable, 
> > I usually 
> > try to make it a structure within a variable, that way when I 
> > do <cfset 
> > variables.user = session.user>, I've got the whole structure (read: 
> > variables.user.myvariable) in one simple statement and I can 
> > do a readonly 
> > cflock scope on it to pull it local to the page.
> > 
> > Once it's a local variable 
> > isdefined('variables.user.myvariable') is no 
> > longer needed to be locked.
> > 
> > ~Todd
> > 
> > On Wed, 12 Jun 2002, Brian Eckerman wrote:
> > 
> > > Is it absolutly necesary to cflock session variables.
> > > ex. when doing an IsDefined(session.myvariable).
> > > How could it hurt to not use them?
> > > 
> > 
> 
______________________________________________________________________
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to