||If you are using ASP 3.0 (the version of ASP that comes with Windows 2000 / IIS 5) then you can use the following syntax:|
where Name is the name of the Session variable you wish to remove. Removing Session variables in this way has its advantages over using the following method:
Namely, the above method (setting a Session variable to
Null) only removes the memory associated with the Session variable itself... the Session object still maintains a reference to it, though. Each Session variables is stored in the Session object with a key/item pair, similar to the
Scripting.Dictionary object. Therefore, using the
Null method above, you are not removing the key from the Session Contents collection that contains the reference to the variable...
Remove method that we looked at first, you are removing both the key and item associated with a Session variable. There is also a
RemoveAll method that can be used to scrap all of the Session variables completely:
RemoveAll methods are new to ASP 3.0. If you have ASP 2.0, you will need to use the
For more information on this, be sure to read: Removing Session and Application Variables. Furthermore, to see how to use the Contents collectoin to programmatically list the contents of the Session (or Application) object, check out: Listing Session and Application Variables.