Arrays that are session persistant

Results 1 to 4 of 4

Thread: Arrays that are session persistant

  1. #1
    Ed Guest

    Default Arrays that are session persistant

    Does anyone know the syntax for building a session level array? Is it even possible?<BR><BR>Thanks in advance,<BR>Ed

  2. #2
    Join Date
    Dec 1969

    Default Popular Topic Today!

    Here&#039s an expansion of a post in another thread today...<BR><BR>If you store an array in a Session object, you should not attempt to alter the elements of the stored array directly. For example, the following script will not work.<BR><BR>&#060;% Session("StoredArray")(3) = "new value" %&#062;<BR> <BR>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 into the collection, overwriting any information stored at that location. <BR><BR>It is strongly recommended that if you store an array in the Session object, you retrieve a copy of the array before retrieving or changing any of the elements of the array. When you are done with the array, you should store the array in the Session object all over again so that any changes you made are saved. This is demonstrated in the following example.<BR><BR>---file1.asp---<BR>&#060;%<BR>&#039Creating and initializing the array<BR>Dim MyArray()<BR>Redim MyArray(5)<BR>MyArray(0) = "hello"<BR>MyArray(1) = "some other string"<BR><BR>&#039Storing the array in the Session object<BR>Session("StoredArray") = MyArray<BR><BR>Response.Redirect("file2.asp")<BR>% &#062;<BR><BR>---file2.asp---<BR>&#060;%<BR>&#039Retrieving the array from the Session Object<BR>&#039and modifying its second element<BR>LocalArray = Session("StoredArray")<BR>LocalArray(1) = " there"<BR><BR>&#039printing out the string "hello there"<BR>Response.Write(LocalArray(0)&LocalArray( 1))<BR><BR>&#039Re-storing the array in the Session object<BR>&#039This overwrites the values in StoredArray with the new values<BR>Session("StoredArray") = LocalArray<BR>%&#062;<BR> <BR>

  3. #3
    Ed Guest

    Default many thanks. see below posts also

    many thanks. see below posts also

  4. #4
    Join Date
    Dec 1969

    Default Popular question all the time...ASPFAQs #63<BR><BR>Enough said? Just click on ASPFAQs at the top of this page.<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts