session变量为何取不到?

shentj 2002-08-01 08:39:24
在验证登录页面里创建一个session变量,验证通过后,进入一个框架页面a,包含两个子页面b和c,此时无论我在框架主页面a里还是在各个子页面b、c里都取不出session变量的值,为什么呢?
...全文
104 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
cat_hsfz 2002-08-02
  • 打赏
  • 举报
回复
最好顺便把password也保存到cookie,否则容易伪造身份
cmsoft 2002-08-02
  • 打赏
  • 举报
回复
<!--#include file="asp/sqlstr.asp"-->
<!--#include file="asp/opendb.asp"-->
<%
Dim username
Dim password
Dim allow
allow=0
username=request("LoginName")
password=request("Password")
if username<>"" and password<>"" then
set conn=opendb("oabusy","conn","accessdsn")
set rs=server.createobject("adodb.recordset")
sql="select * from userinf where username=" & sqlstr(username)
rs.open sql,conn,1
if (not rs.eof) then
if (trim(rs("password")))=password then
session("username")=rs("username")
response.redirect "../index.htm"
end if
else
response.redirect "../opportunities/fail1.htm"
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
end if
%>

shentj 2002-08-02
  • 打赏
  • 举报
回复
登录验证源码如下,环境是winnt+iis4.0:
<!--#include file="asp/sqlstr.asp"-->
<!--#include file="asp/opendb.asp"-->
<%
Dim username
Dim password
Dim allow
allow=0
username=request("LoginName")
password=request("Password")
if username<>"" and password<>"" then
set conn=opendb("oabusy","conn","accessdsn")
set rs=server.createobject("adodb.recordset")
sql="select * from userinf where username=" & sqlstr(username)
rs.open sql,conn,1
if (not rs.eof) then
if (trim(rs("password")))=password then
allow=1
end if
else
allow=2
end if
rs.close
set rs=nothing
conn.close
set conn=nothing

if allow=1 then
' session("username")=username
response.redirect "../index.htm"
else
response.redirect "../opportunities/fail1.htm"
end if
end if
%>

index.htm是一个框架页,包含三个页面
zhusuhao 2002-08-02
  • 打赏
  • 举报
回复
你要是光创建没用,你要给它赋值,然后他才能把那个值传到别的页面。
shentj 2002-08-02
  • 打赏
  • 举报
回复
cmsoft,你好,我在验证页面已经创建一个session变量了

为什么呀?
cmsoft 2002-08-01
  • 打赏
  • 举报
回复
你在登录后的session赋值了没有啊?

28,409

社区成员

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

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