Sorry if this has been covered, I couldn't find anything specifically to this issue in my searches.
I am trying to debug a classic ASP application. I need to print the session variables, one of which is an array. My code is below, I keep getting Subscript out of range, usually this means that the array is empty (Ubound returns -1) but in this case it's coming back as 9. I've tried For i = 1 To 4
and For i = 0 To 4
with the same results.
For Each Item In Session.Contents
If IsArray(Session(item)) Then
localArray = Session(item)
Response.Write "<h1>Ubound = " & Ubound(localArray) & "</h1> <br />" //getting Ubound = 9 here
For i = 1 To Ubound(localArray)
Response.Write "<br> " & item
Response.Write "(" & i & ") = " & localArray(i)
Next
Elseif IsObject(Session(item)) Then
Response.Write "<b>" & item & " is an object </b>"
Else
Response.Write item & " = " & Session(item)
End If
Response.Write "<br>"
Next
EDIT
Changed code to
For i = LBound(localArray) To UBound(localArray)
Have also tried
localArray = Session(item)
Response.Write localArray(2) //since UBound returns 9 figured 2nd index should be safe
I still receive the error, it seems like the array may not be single dimension. However I am not familiar with the structure or creation of this session variable, is there a way to get the structure of an array in ASP?