Better yet, create another level under the SESSION structure and create
your session-level structures and arrays there.  It becomes very easy to
whack your one session-specific level when you want to delete or
re-initialize all of your user's session-specific information.

I would use "SESSION.TLA" -- Where TLA stands for an abbreviation for
your web-site -- instead of "SESSION".

We have found that doing this allows our developers to do what they must
without clashing with CF. 

Robert Miller
Promises Kept, LLC
www.promises-kept.com
email: [EMAIL PROTECTED]
direct: 480.998.2918
fax:     413.845.7357
 

-----Original Message-----
From: Dave Watts [mailto:[EMAIL PROTECTED]] 
Sent: Monday, February 25, 2002 5:21 PM
To: CF-Talk
Subject: RE: Need to delete to delete a struct key before reassigning
it?

> My coworker has a couple of times brought up the fact 
> that in some places I reset a variable without deleting 
> it. For example, if when looking at a user's session 
> variable, if I find it to be out of date I reset by
> <CFSET session = StructNew()>
> 
> Or if I just need to reset their basket contents I use:
> StructInsert(session,"basket",ArrayNew(1));
> 
> Instead, he would use:
> StructDelete(session,"basket");
> StructInsert(session,"basket",ArrayNew(1));
> 
> Is there any problems with the way I'm doing it? He is 
> concerned that it may leave some stuff out in memory.

CF, being a high-level language, has its own garbage collection, so you
don't have to worry about this kind of stuff. It's just as good to
overwrite
a variable as it is to delete it and recreate it - even better, from a
performance point of view.

However, it's worth pointing out that in your first example, you have:

<cfset session = StructNew()>

You'll want to be careful with that. CF creates a few session variables,
and
can get confused if you delete them. I'd recommend just deleting the
variables that you've created.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444

______________________________________________________________________
Why Share?
  Dedicated Win 2000 Server � PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc
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