[thelist] CF: Moving a struct to a session.var

Raymond Camden jedimaster at macromedia.com
Thu Aug 15 07:18:01 CDT 2002


> ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> > // Copy this struct to a session variable
> > Session.ContactDetails=StructNew();
> >
> > Session.ContactDetails=StructCopy(ContactDetails);
> ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
>
> use the Duplicate() function instead since the StructCopy()
> function creates a reference to the local copy instead of
> creating a new copy.

StructCopy _will_ create a copy, but only if the structure is 'simple',
ie, contains keys with values that are strings. The problem with
structCopy comes up when the struct you copy has a key that is a struct
itself (or an array w/ structs, etc). In general, never use structCopy.
(Sorry for being anal. ;)

=======================================================================
Raymond Camden, ColdFusion Jedi Master for Hire

Email    : jedimaster at macromedia.com
Yahoo IM : cfjedimaster

"My ally is the Force, and a powerful ally it is." - Yoda





More information about the thelist mailing list