ASP Variables
Variables are used to store information.
Try it Yourself - Examples
Declaring Variables
Variables are used to store information. This example demonstrates how to declare a variable, assign a value to it, and use it in a program.
Declaring Arrays
Arrays are used to store a series of related data items. This example demonstrates how to declare an array that stores names.
Generating HTML Headings with Loops
This example demonstrates how to use a loop to generate 6 different HTML headings.
Creating Time-Based Greetings with VBScript
This example demonstrates how to display different messages to users based on the server time.
Creating Time-Based Greetings with JavaScript
This example is the same as the one above, demonstrating how to display different messages to users based on the server time, just with different syntax.
The Lifetime of Variables
Variables declared outside a subroutine can be accessed and modified by any script in the ASP file.
Variables declared inside a subroutine are created and destroyed each time the subroutine is executed. Scripts outside the subroutine cannot access or modify these variables.
To declare variables for use by multiple ASP files, declare them as Session variables or Application variables.
Session Variables
Session variables are used to store information about a single user and are valid for all pages in an application. Typical information stored in a Session includes name, ID, and parameters.
Application Variables
Application variables are also valid for all pages in an application. Application variables are used to store information for all users in a specific application.
Other Extensions