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

Posted on 2008-11-04
Last Modified: 2013-11-07

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...
Question by:praetorean
    LVL 20

    Expert Comment

    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.


    Author Comment

    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...

    LVL 20

    Accepted Solution

    - 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

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now