I.T. Discussion Community!
-Collapse +Expand
ASP Classic
Search ASP Classic Group:

-Collapse +Expand ASP Classic Store

Prestwood eMagazine

March Edition
Subscribe now! It's Free!
Enter your email:

   ► KBWebsite Scri...ASP ClassicLanguage Basics   Print This    All Groups  
  From the November 2015 Issue of Prestwood eMag
ASP Classic Language Basics:
Clear Application and Session Variables Using ASP classic
Posted 14 years ago on 2/16/2007 and updated 5/1/2010
Take Away:

Use Application.Contents.RemoveAll and Session.Contents.RemoveAll


You can use Application.Contents.RemoveAll and Session.Contents.RemoveAll. The following code removes all session and application variables using ASP classic:


You can also remove a single application or session variable with Application.Contents.Remove and Session.Contents.Remove. For example, the following code removes ONE application variable and ONE session variable:


Other Things That Clear Session and Application Variables

In addition to your code explicitly clearing application and session variables, there are a number of other instances where they are cleared. For example:

  • Web Server Recycled - For example with a server restart or when IIS detects a web server recycle is needed (see App Pools).
  • When you copy a new Global.asa file to your web server.

Unreliable Session and Application Variables

Sometimes session and application variables are unreliable. For example, in a load balancing scenario, they are spread over multiple web servers, app pools, or web gardens (see Web Gardens).

Application Variables and Web Gardens

If you are running your own IIS server, you'll want to set your Web Gardens value to 1 so that you don't virtualize your web server session and application variables.

In Internet Information Services (IIS) Manager, select your server, Application Pools, right click on your app pool, select Properties. On the Performance tab, adjust the Maximum number of worker processes.

More Info


Share a thought or comment...
Write a Comment...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.

Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P134A1
Enter key:
KB Post Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains play-drums.com and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile

 KB Article #100452 Counter
Since 4/2/2008

Follow PrestwoodBoards on: 

©1995-2021 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech