473,555 Members | 2,307 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about session objects and condition...

Hi,

I've got the following code that sets a session object.
set obj = server.createob ject("Scripting .Dictionary")
set session("testob j") = 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("testob j") = null
2 --> set session("testob j") = nothing
3 --> Session.Content s.Remove("testo bj")

If I want to check if the session object is not exist, which is the
best option?
1 --> if (session("testo bj") = null) then ...
2 --> if (session("testo bj") = nothing) then ...
3 --> if (isobject(sessi on("testobj")) ) then ...

Any suggestions are welcome...

Thanks,
June...
Jul 22 '05 #1
2 1560
"June Moore" <ju******@yahoo .com.au> wrote in message
news:e5******** *************** ***@posting.goo gle.com...
: Hi,
:
: I've got the following code that sets a session object.
: set obj = server.createob ject("Scripting .Dictionary")
: set session("testob j") = 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("testob j") = null
: 2 --> set session("testob j") = nothing
: 3 --> Session.Content s.Remove("testo bj")

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("testo bj") = null) then ...
: 2 --> if (session("testo bj") = nothing) then ...
: 3 --> if (isobject(sessi on("testobj")) ) then ...

if session("testob j") = "" 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.createob ject("Scripting .Dictionary")
set session("testob j") = 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("testob j") = null
2 --> set session("testob j") = nothing
3 --> Session.Content s.Remove("testo bj")
2 is best

If I want to check if the session object is not exist, which is the
best option?
1 --> if (session("testo bj") = null) then ...
2 --> if (session("testo bj") = nothing) then ...
3 --> if (isobject(sessi on("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
7180
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 some properties objUserInfo.UserName = txtUserName.text.trim objUserInfo...
29
3138
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. Anything out there in Php?
4
2060
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 (read as: no discernable pattern at this point), HTTP requests from users result in a 'Server Application / Error.' The user requests a page and the...
10
7862
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 the URL, in the format http://yourapplicationpath/(Session.SessionID)/... which saves numerous headaches when it comes to storing state across page...
1
3538
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 the column header. He showed me how he was creating the page, and we had a question about the wizard that sets up the connection. In it, he had to...
29
3544
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 one data field - but i'm not sure) :-) Background info:
0
922
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 head over C# 2.0 iterators and I am not able to get this right. public static IEnumerable<TGetObjects(IEnumerable<Tobjects) { foreach(T x in...
0
1138
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 first concern would be to separate the business logic code from data contener : the new code would look like that :...
2
1008
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, I notice that only stuffs related to SessionID are stored in the database. None of my session objects such as Session.Contents, Session.Contents...
0
7547
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8060
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6176
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5171
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3596
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1159
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
865
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.