473,698 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Proper way of destroying unused session objects

Hello,

I am carrying some values into a page using Session object. I would
like to remove the session values that I used on this page [not to
overcrowd session] when the user leaves to another page. But I need
these values as long as user is on this page [If user presses page
refresh, these Session variables must not be erased].

My environment is ASP.NET/VB.NET.
Thanks in advance
-NET User
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 18 '05 #1
3 2816
NETUser2004 wrote:
Hello,

I am carrying some values into a page using Session object. I would
like to remove the session values that I used on this page [not to
overcrowd session] when the user leaves to another page. But I need
these values as long as user is on this page [If user presses page
refresh, these Session variables must not be erased].

My environment is ASP.NET/VB.NET.
Thanks in advance
-NET User
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com


A trick I picked up is to have a 'temp bucket', 1 session var which
contains a Hashtable where you can store the values for that page. Then
when the next page loads itself, all it has to do is Clear the Hashtable
entries in that Session var. Pseudo code:

Hashtable ht = new Hashtable()
ht.Add("var1"," val1")
ht.Add("var2"," val2")
Session["tempbucket "] = New Hashtable()

then on the next page (when this page is no longer being visited), you
can clear the Hashtable (I'd recommend) or write over the 'tempbucket'
variable with a new hashtable.

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #2
Sorry, some of my reply's code is C# syntax (which is why I marked it
pseudo code, not in front of VS.NET right now)...you should get the idea
though......

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #3
"NETUser200 4" <bi*********@ya hoo-dot-com.no-spam.invalid> wrote in message
news:40******** **@Usenet.com.. .
Hello,

I am carrying some values into a page using Session object. I would
like to remove the session values that I used on this page [not to
overcrowd session] when the user leaves to another page. But I need
these values as long as user is on this page [If user presses page
refresh, these Session variables must not be erased].


Why bother removing the values? Have you performed a performance analysis
which suggests that removing them will increase your application's
performance?
--
John Saunders
John.Saunders at SurfControl.com
Nov 18 '05 #4

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

Similar topics

3
4684
by: Marcus | last post by:
I know from php.net that when register_globals is turned on, session_start(); session_unset(); session_destroy(); will succeed in unsetting all session variables and then destroying the session. I also read on the site that when using $_SESSION, you shouldn't use session_unset, but instead should use unset() to accomplish the 2nd of the above tasks. This example is then given:
3
18471
by: Pete | last post by:
I have a site which is using sessions to pass data from one page through to the next. The problem that I have is that there are only two places where the session could/should be destroyed. This is where a form is printed using : <input type="button" name="Button" value="Print Order" onClick="window.print();"> or when the order form is reset using a JavaScript function :
2
1630
by: STEPHEN GOODE | last post by:
I have a need to notice when a user leaves a site so I can implement destructors for objects. I know that PHP doesn't supply an object destructor. I can code that myself. What I don't know how to do is know when a session is no longer needed, for example, when a user leaves the site or closes the browser. I thought that register_shutdown_function() would help, but it shuts down at the end of the session regardless of whether I plan to...
3
3038
by: SB | last post by:
Hi, Is anyone aware of any freeware/shareware tools that can assist in identifying unused objects in a database? I have inhertited a database from a previous developer, and there seems to be a lot of unused queries and code in the database. I know of Total Access Analyser from FMS, but my boss won't agree to the purchase due to the current conversion rate from $USD to $AUD, making this about $500.00 Australian to purchase, which he says...
2
1333
by: jaymtz78 | last post by:
Hi, I have a huge windows application that I'm working on and I'm completely baffled. Sometimes when I try to close the application, it won't let me! I have an Exit button in my menu bar that has Application.Exit and works all the time, but if I try to Alt + F4 or click the 'X' in the Control Box...it won't let me exit the application sometimes unless I test to see if the 'X' was clicked and the use Application.Exit there too. I...
6
1474
by: Varangian | last post by:
Hi there, I was testing with sessions lately and wanted to destroy a particular session. If I have two sessions at the same page being used. Session = "testing1"; Session = "testing2"; on using the Session.Abandon(); .... which one of them is destroyed
9
3186
by: ThazKool | last post by:
I am just wondering if all the methods that are never called upon during a programs execution are removed when optimizing. For example you have: class FooA { void a(); ... void z(); }
4
2702
by: Olumide | last post by:
Hello - I have two classes A and B as follows: class B{ public: ~B(){ cout << "destroying B" << endl; } }; class A{
41
1878
by: =?Utf-8?B?VGltIE1hcnNkZW4=?= | last post by:
Hi, I am after suggestions on the best practice declaring and destroying objects. some example code: Private Sub MySub Dim frmMyForm As MyForm Try
0
8672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8600
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8860
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3038
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
2
2323
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1998
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.