暂时初学者 发布留言 2008-11-13 15:57
用session保存用户的方法--有问题
建了个redirect.asp内容是
<%
if Session("username")<>"" then
response.redirect("main.asp")
end if
%>
然后在index.asp的开头放
在check.asp里验证成功的条件后面加Session("username")=uname
但是MS没用。谁可以帮我找下原因不。
要是不是这样写的话,应该是怎么写的。谢谢了!
hmhz 发布留言 2008-11-13 16:01
MS 是什么?
暂时初学者 发布留言 2008-11-13 16:03
MS=貌似....呵呵
hmhz 发布留言 2008-11-13 16:04
什么叫没用?你是说Session("username")=uname没有把名字保存到Session("username")里去?
暂时初学者 发布留言 2008-11-13 16:08
嗯,是这样的。输入用户名之后,进入check页面。然后就转不到main页面了。把session注释掉又正常了
暂时初学者 发布留言 2008-11-13 16:12
版主,这代码有错吗?
hmhz 发布留言 2008-11-13 16:13
check 页面代码发出来看看
暂时初学者 发布留言 2008-11-13 16:15
<%
uname=trim(Request.Form("name"))
upassword=trim(Request.Form("password"))
set rs=Server.CreateObject("Adodb.Recordset")
sql="select * from [login] where uname='"&uname&"' and upassword='"&upassword&"' "
rs.open sql,conn,1,1
if rs.recordcount=0 then
response.write("")
else
Session["username"]=uname
response.write("")
end if
rs.close
set rs=nothing
%>
yms123 发布留言 2008-11-13 16:40
Session["username"]=uname
这里错了
在ASP里存储Session不用中括号
Session("username")=uname
暂时初学者 发布留言 2008-11-13 16:43
我是用用()没用,才试了用[]的..还是一样。[em13]
yms123 发布留言 2008-11-13 16:46
<%
Session.timeout=30'这里强制Session的过期时间为30分钟。
uname=trim(Request.Form("name"))
upassword=trim(Request.Form("password"))
set rs=Server.CreateObject("Adodb.Recordset")
sql="select * from [login] where uname='"&uname&"' and upassword='"&upassword&"' "
rs.open sql,conn,1,1
if rs.recordcount=0 then
response.write("")
else
Session["username"]=uname
response.write("")
end if
rs.close
set rs=nothing
%>
暂时初学者 发布留言 2008-11-13 16:47
在check页面...动不了...状态栏显示的是"等待192.168.1.3/main.asp"
跳转不到main.asp
192.168.1.3是本机ip
暂时初学者 发布留言 2008-11-13 16:49
redirect.asp的代码
<%
if Session("username")<>"" then
response.redirect("main.asp")
end if
%>
yms123 发布留言 2008-11-13 19:37
那就不简单是Session问题了,main.asp可能有问题
页: [1]