session| Variable | Array If you store an array in a sessions object, you should not attempt to alter the elements of the stored array directly. For example, the following script won't work:
<% session ("StoredArray") (3) = "New Value"%>
This is because the session object is implemented as a collection. The array element StoredArray (3) does not receive the new value. Instead, the value is indexed to the collection, overwriting any information stored in that location.
It is strongly recommended so if you store an array in the Session object, you retrieve a copy of the array before Retri Eving or changing any of the elements of the array. When you are do with the array, you should store the "array in" the Session object again so any changes you made are Saved. This is demonstrated in the following example:
---file1.asp---
<%
' Creating and initializing the array
Dim MyArray ()
Redim MyArray (5)
MyArray (0) = "Hello"
MyArray (1) = "Some other string"
' Storing the ' array in the Session object.
Session ("StoredArray") = MyArray
Response.Redirect ("file2.asp")
%>
---file2.asp---
<%
' Retrieving the ' array from the session Object
' and modifying its second element.
LocalArray = Session ("StoredArray")
LocalArray (1) = "There"
' Printing out the string ' Hello there.
Response.Write (LocalArray (0) &localarray (1))
' Re-storing the ' array in the Session object.
' This overwrites the values in StoredArray with the new values.
Session ("StoredArray") = LocalArray
%>