跪求:遍历session对象代码

creater 2005-04-09 01:25:39
<%
For Each item in request.ServerVariables
response.Write(item & "=" &request.Server Variables(item) & "<BR>")
Next
%>

上面这段代码可以遍历request对象,请问有没有办法遍历session对象啊??(asp、jsp都可)
...全文
135 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
creater 2005-04-09
  • 打赏
  • 举报
回复
hbhbhbhbhb1021(天外水火)
你的分单独给了哦!!!
libaisongtuye 2005-04-09
  • 打赏
  • 举报
回复
分这么多,俺来接分
jFresH_MaN 2005-04-09
  • 打赏
  • 举报
回复
web版抢分不容易啊!
creater 2005-04-09
  • 打赏
  • 举报
回复
呵呵,本来想把这个也结了的:)
jFresH_MaN 2005-04-09
  • 打赏
  • 举报
回复
jsp的

for (Enumeration e = session.getAttributeNames(); e.hasMoreElements() ;) {
Object o=session.getAttribute((String)e.nextElement());
}

汗。。。
刚才在楼主的上一个帖子回复了
没想到刚写完,竟然揭贴了!!
creater 2005-04-09
  • 打赏
  • 举报
回复
当时注册这个ID的时候,过了大半年才收到,以前不用每天登录就可以加分的,到手上就已经积了几千分了,可且又很少提问,现在穷得只剩下分了,汗。。。。。。。。
wxf0104 2005-04-09
  • 打赏
  • 举报
回复
我会骗人的方法也不错,收藏~~
wxf0104 2005-04-09
  • 打赏
  • 举报
回复
天外水火的方法很好的哟~~

学习
myvicy 2005-04-09
  • 打赏
  • 举报
回复
<%@ LANGUAGE="VBSCRIPT" %>
<%
Dim sessitem
Dim anArray(2)
response.write "SessionID: " & Session.SessionID & "<P>"

anArray(0)="one"
anArray(1)="second"
anArray(2)="third"
Session("anArray")=anArray
Session("scalar")="1234567890ABCDEFG"

set objConn=server.createobject("adodb.connection")
set Session("object")=objConn

response.write "List of " & Session.Contents.Count & " items in Session
contents collection:<HR>"
For Each sessitem in Session.Contents
If IsObject(Session.Contents(sessitem)) Then
Response.write(sessitem & " : Session object cannot be displayed." & "<BR>")
Else
If IsArray(Session.Contents(sessitem)) Then
Response.write "Array named " & Session.Content(sessitem) & "<ol>"
For each objArray in Session.Contents(sessitem)
Response.write "<li>" & _
Session.Contents(sessitem)(objArray)& "<BR>"
Next
Response.write "</ol>"
Else
Response.write(sessitem & " : " & Session.Contents(sessitem) & "<BR>")
End If
End If
Next
%>

themedy 2005-04-09
  • 打赏
  • 举报
回复
楼主分多,来接分得了
lstup 2005-04-09
  • 打赏
  • 举报
回复
session(i)
hbhbhbhbhb1021 2005-04-09
  • 打赏
  • 举报
回复
楼主分多啊
<%@ LANGUAGE=VBScript codepage ="936" %>
<% Option Explicit %>
您的sessionID号是:<%=session.sessionid%><br>
<%
Response.Write "在你的程序中一共使用了 " & Session.Contents.Count & _
" 个Session变量<P>"
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
%>

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧