栏目导航
热点推荐
- ASP下批量删除数据的两种方法
- 关于二级域名共享cookies
- ASP错误代码大全
- ASP代码实现show.asp?id=26变成s
- ASP错误信息解决:IIS启用父路径
- 一些常用的正则表达式大全
- ASP超级链接和HTML函数正则表达
- ASP隐藏下载地址及防盗代码
- 最常用的正则表达式示例
- ASP程序数据库被挂马的处理方法
- ASP生成html的新方法
- 精通ASP错误提示大全
阅览排行
ASP所有的Session变量获取实现代码
www.jz123.cn 2010-01-07 来源: 中国建站 责任编辑(袁袁) 我要投递新闻
在程序调试中,有时候需要知道有多少Session变量在使用,她们的值如何?由于Session对象提供一个称为Contents的集合(Collection),我们可以通过For...Each循环来达到目标
Dim strName, iLoop For Each strName in Session.Contents Response.Write strName & " - " & Session.Contents(strName)& "[BR]" Next |
一般情况下,上面的代码可以工作得很好。但当Session变量是一个对象或者数组时,打印的结果就不正确了。 这样我们修改代码如下:
'首先看看有多少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 '其他情况,就简单打印变量的值 Response.Write strName & " - " & Session.Contents(strName) & "<BR>" End If Next |
'首先看看有多少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
'其他情况,就简单打印变量的值
Response.Write strName & " - " & Session.Contents(strName) & "<BR>"
End If
Next
<%@ ENABLESESSIONSTATE=True %> |
而其他页面设置为:
<%@ ENABLESESSIONSTATE=False %> |
上一篇:asp 网站静态化函数代码html 下一篇:一些常用的正则表达式大全