June Moore wrote:
Hi,
I've got the following code that sets a session object.
set obj = server.createobject("Scripting.Dictionary")
set session("testobj") = obj
If I want to remove the session object, do each of the following does
the same job? Which one is the best?
1 --> set session("testobj") = null
2 --> set session("testobj") = nothing
3 --> Session.Contents.Remove("testobj")
2 is best
If I want to check if the session object is not exist, which is the
best option?
1 --> if (session("testobj") = null) then ...
2 --> if (session("testobj") = nothing) then ...
3 --> if (isobject(session("testobj"))) then ...
Again, 2 works fine, but ...
Any suggestions are welcome...
Just to reinforce Roland's message: the Dictionary object is NOT safe to
store in Session or Application. Doing so WILL impair your server's
performance. If you absolutely must store a data structure more complex than
an array in session, consider using an XML free-threaded DomDocument, which,
as the name implies, is free-threaded, and is therefore a good choice to
store in Session/Application. You can find the documentation for this at
msdn.microsoft.com/library.
With ASP.Net, the restriction about storing objects in session disappears,
so you may wish to consider taking that leap.
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"