Session.SessionID,比较时出错,我实在是没有搞懂!!!

Lixh2000 2005-10-16 06:24:12
我想判断一个用户是否打开新窗口重新登陆,如果开新窗口重新登陆了,则原有会话失效。用户在登陆时登记了SessionID,并将用户名存在Session("UserID")中。我用了Session("LoginError")来记录出错信息。

代码如下:

Set rs = conn.Execute("select * from employees_admin where admin_name='" & Session("UserID") & "'")
If Session.SessionID <> rs("admin_sessionid") Then
Session("LoginError")="用户已重新登陆,此会话过期!" & rs("admin_sessionid") &"."& Session.SessionID
Response.Redirect "default.asp"
rs.Close
End If

按说我在第一次登陆时上面的IF语句应该不会执行,可结果却是:

用户已重新登陆,此会话过期!196435399.196435399

明明Session.SessionID 和 rs("admin_sessionid") 的值相等,为什么那个不等式会成立呢?

...全文
214 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
ytycoffe 2005-10-18
  • 打赏
  • 举报
回复
长整型 的数据也可以比较的
If Session.SessionID <> rs("admin_sessionid") Then

-->

If Clng(Session.SessionID) <> Clng(rs("admin_sessionid")) Then
Lixh2000 2005-10-18
  • 打赏
  • 举报
回复
顶一下
Lixh2000 2005-10-16
  • 打赏
  • 举报
回复
SessionID
The SessionID property returns the session identification for this user. Each session has a unique identifier that is generated by the server when the session is created. The session ID is returned as a LONG data type.

jspadmin 2005-10-16
  • 打赏
  • 举报
回复
sessionid每次都是随即生成的,而且默认系统20分钟过后session就失效
pisces_fri 2005-10-16
  • 打赏
  • 举报
回复
admin_sessionid 字段设置成文本或字符类型看看。
ShiningstarHu 2005-10-16
  • 打赏
  • 举报
回复
If Session.SessionID <> rs("admin_sessionid") Then

-->

If CStr(Session.SessionID) <> CStr(rs("admin_sessionid")) Then
xshsoft 2005-10-16
  • 打赏
  • 举报
回复
SessionID不是长整型,是字符串型

Property SessionID As String
read-only
Member of ASPTypeLibrary.Session
Returns a Session ID for this user.
Lixh2000 2005-10-16
  • 打赏
  • 举报
回复
If Session.SessionID <> rs("admin_sessionid") Then

-->

If CStr(Session.SessionID) <> CStr(rs("admin_sessionid")) Then


用CStr()转换一下结果是对的,但是Session.SessionID不是长整型的数据吗?我在SQL中设置字段为4位的int类型,难道不行吗?长整型数据不可以比较吗?

28,390

社区成员

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

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