This doesn't make any sense.
A session represents the time that a visitor arrives at your site to the
time they leave, regardless of what pages they visit in between. To be
creating session variables on a page and then destroying them on that same
page defeats the purpose of session.
If you only need the data on a particular page, just use regular page
variables.
If you really do need to keep data between different pages, consider using
cross-page postbacks, querystrings (if applicable), cookies, a database, or
of course sessions.
But, generally, you don't need to worry about manually clearing the session
values, as they will be dropped when the session times out (normally 20
minutes, but you can bring that number down if you like).
Just curious, why is ViewState not an option?
"Geo" <Ge*@discussions.microsoft.comwrote in message
news:84**********************************@microsof t.com...
Alright, I believe I am not clear here..
Every page has lots of data and i use on an average of 10 sessions a page.
I
want to clear them out when I finish using them whether it is within a
page
or within pages.
I could use Session.Remove, but I am afraid that I could miss some
sessions.
Also where would I be calling these session.remove methods? On Page load?
Since I use menu to navigate - every screen must have these methods?
I am looking for a Page_unload event which fires when the page unloads -
EVEN when the menu is clicked. Page_Unload fires only when the current
page
changes but not from the menu..
Geo.
"Jonathan Wood" wrote:
>By sessions, do you mean the Session collection?
If so, it's not clear to me why you'd want to clear it when leaving a
page
as the only reason to use the Session collection is to store data between
page requests.
But Session items can be removed using one of several methods:
Session.Clear();
Session.RemoveAll();
Session.Remove(itemName); // Removes only the specified item
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Geo" <Ge*@discussions.microsoft.comwrote in message
news:6C**********************************@microso ft.com...
Hi, I use lots of sessions. I want to clear the unwanted sessions when
I
leave a page. I cant use ViewState as it will slow down the pages.
Could
some
one help me on this?