473,408 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Question about session objects and condition...

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")

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 ...

Any suggestions are welcome...

Thanks,
June...
Jul 22 '05 #1
2 1553
"June Moore" <ju******@yahoo.com.au> wrote in message
news:e5**************************@posting.google.c om...
: 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")

It is my understanding in ASP 3.0 the first two zero out the value but do
not remove the object.
http://www.aspfaqs.com/webtech/102900-1.shtml

Before you start storing objects in session variables, you should read the
following:
http://www.learnasp.com/learn/sessionoverview.asp

To remove all session objects: Session.Abandon

: 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 ...

if session("testobj") = "" then ...

http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=74
http://www.microsoft.com/windows2000...p/iiapsess.htm
http://www.w3schools.com/asp/asp_sessions.asp

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #2
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"
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Billy Jacobs | last post by:
I am having a problem with my session variable being set to Null for no apparent reason. I am declaring it like the following when the user logs in. dim objUserInfo as new clsUserInfo 'Set...
29
by: Mainlander | last post by:
An ISP I belong to uses Majordomo for their mailing list system. I'd like to encourage them to move to a system that uses a database, preferably psql which they already run on their server....
4
by: John Wilcher | last post by:
Environment: Windows 2000 Server, IIS 5.0, ASP .Net Framework 1.1, VB .Net source code We are experiencing a condition that manifests itself as a loss of all session objects. Intermittently...
10
by: Anthony Williams | last post by:
Hi gang, This one looks like a bug :o( As you may or may not know, setting session management in web.config to use cookieless sessions causes the ASP.NET runtime to munge a session ID into...
1
by: Goober at christianDOTnet | last post by:
A friend of mine is doing some datagrids on a web page, and was using the SQL data adapter on the design view of the page. He is sorting the datagrid on each of the columns as a user clicks on...
29
by: MP | last post by:
Greets, context: vb6/ado/.mdb/jet 4.0 (no access)/sql beginning learner, first database, planning stages (I think the underlying question here is whether to normalize or not to normalize this...
0
by: Dilip | last post by:
Given a bunch of IEnumerable<Tobjects, how do I iterate through them and do a yield return on objects that satisfy one condition and objects that satisfy another condition? I am still wrapping my...
0
by: =?Utf-8?B?SmVhbi1GcmFuY29pcyBCcmV0b24=?= | last post by:
"siddharthkhare@hotmail.com" wrote: The context is important in this kind of design concern : I assume there's a lot of user and that application will evolve to add richer functionality. My...
2
by: gnewsgroup | last post by:
For asp.net web application, I had thought that using SQL Server Session State management would imply that all session objects be stored in SQL Server database ASPState. But when I look into it,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.