You can declare variables anywhere in your scripting blocks in your ASP pages. You can declare a variable within a Function/Sub Routine or you can declare it outside. The variables declared within a Function/Sub Routine are accessible only from this Function/Sub Routine, while the ones declared outside are accessible from everywhere in your ASP page, including any Functions/Sub Routines.
The variables declared in Function/Sub Routine exist only during the execution of Function/Sub Routine. The variables declared outside of Functions/Sub Routines exist while the APS page is executed (once the ASP page execution is completed, these variables are gone).
Sometimes you will need to have variables, which are accessible from all APS pages within one ASP application and you can accomplish that by using Session and Application variables. We’ll talk about the Session and Application ASP objects, later in this tutorial. For now it’s enough for you to know that Session variables store information about one user session (different users browsing your website will have different Session variables), while Application variables are the same for all users browsing the ASP application.