Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5607
  • Last Modified:

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...
  • 2
1 Solution
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.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now