destroy/delete/remove/clear page specific session variables...


I just want to verify as to where it'd be best to destroy/delete/remove/clear (for the lack of a better tech lingo) page specific session variables. I understand that .net has session management mechanisms (I do not have the time to look into this, I am looking for a quick fix for now...), but I was wondering where it'd be best to be able to do so manually...

I have been thinking of clearing the page specific session variables  at page's unload event, but I am adamant as I am not certain if this would be the best place to do...
Essentially, I just want to be able to clear page specifc session variables when I close the page (clicking on the x button on the upper-right corner)

scenario is as follows: when a page is opened for processing... session variables are created. then when the user closes the page, those session variables that have been created should be cleared.

Thanks in advance...
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi praetorean,
In ASP.NET, when the user closes the browser, the Session items stored in the HttpSessionState object are automatically deleted, because the mentioned object is unique per session, so, basically, you don't have to do anything.

praetoreanAuthor Commented:
I see...

so Session variables initialized/assigned/manipulated are specific to a page's instance...
would to confirm the following:
--session variables created from a webform would be page specific, hence destroyed when the page is closed/unloaded...

--session variables created from a global asax's event's would specific to the instance of an entire web app...

- Session variables are specific the user session.
- Application variables are specific to the application, and get created / destroyed every time the application restarts.

But, it's important to note that this is not related directly with global.asax: You can create Session and Application variables in any part of the application.
In global.asax what you can do is to handle Session and Application EVENTS.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.