我想列出来所有的Session变量代码应该怎么写呢ASP
ASP列出程序中所有的Session变量,程序通过IF来判断Session变量是否为数组,如果是数组,则列出所有Session数组元素,若不为数组,则直接显示出这些变量。数组的情况下,使用For循环遍历数组元素,并逐一列出Session变量名。
<% Option Explicit Dim strName, iLoop For Each strName in Session.Contents '判断Session变量是否为数组 If IsArray(Session(strName)) then '如果是数组,列出所有数组元素 For iLoop = LBound(Session(strName)) to UBound(Session(strName)) Response.Write strName & "(" & iLoop & ") - " & _ Session(strName)(iLoop) & "<BR>" Next Else '若不是数组,则直接显示 Response.Write strName & " - " & Session.Contents(strName) & "<BR>" End If Next %>