Creating Session arrasy and variables in ASPAt any time we can create a session variable and store data in it. Let us try to store user name in our session variable. We have given the name of our session variable as name only. Here is the example
session("name")=nameNote that the variable name has the name of the user and now it is available as a session variable. Let us learn how to display this session variable.
Response.Write "Welcome " & session("name")Above line will display a welcome message with the user name. Now let us try to display how many session variables are present for the user or the total number of session variables present for the user.
Response.Write Session.Contents.CountThe above line will display a number as total number of session variables present in our user session.
Removing all values from Session VariablesWe can destroy or remove all session variables like this .
Selectively removing session valuesThere may be a requirement of selectively removing some session variables. Let us learn that . Here is an example of removing one particular session variable.
ASP Session arrayWe can store array in our session and carry that to different pages in ASP. We will learn how to assign a session array from a local array. Display all elements from a session array and how to assign a local array from session array.
Let us take the example of a simple array and assign some elements to it.
For our learning let us display all elements of the array once.