ASP Variables
Variables are used to store information.
Try it - Example
Declare 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.
Looping to generate HTML headings
This example demonstrates how to generate 6 different HTML headings in a loop.
Creating a time-based greeting with VBScript
This example demonstrates how to display different messages to users based on the server time.
Creating a time-based greeting with JavaScript
This example is the same as above, demonstrating how to display different messages to users based on the server time, only 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 runs. Scripts outside the subroutine cannot access or modify the variable.
To declare a variable for use by multiple ASP files, declare it as a session variable or an application variable.
Session variables
Session variables are used to store information for a single user and are available to all pages in an application. Typical information stored in a Session includes name, id, and parameters.
Application variables
Application variables are also available to all pages in an application. Application variables are used to store information for all users of a particular application.