用于asp中遍历session的代码

Response.Write "There are " & Session.Contents.Count & " Session variables<P>"    
Dim   strName,   iLoop    
'使用For   Each循环察看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    
'其他情况,就简单打印变量的值    
    For Each strName in Session.Contents    
        Response.Write strName & " - " & Session.Contents(strName)& "<BR>"    
    Next  
end   if

猜你喜欢

转载自blog.csdn.net/dreamiii/article/details/8255117