我把两个文件的内容发上来
login.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%'Response.CodePage=65001%>
<%'Response.Charset="UTF-8"%>
<%
if session("login")<>"" then
response.Redirect("index.asp")
response.End()
end if
%>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="Author" content="登陆测试"/>
<meta http-equiv="Content-Type" content="<%=header%>; charset=utf-8" />
<link rel="stylesheet" href="style.css" type="text/css"/>
<title>登陆测试</title>
</head>
<body>
<div id="container" " & name & "' and AcctPwd = '" & password & "'"
set rs = CreateObject("ADODB.Recordset")
rs.open CheckNameSQL,conn,1,1
if rs.eof AND rs.bof then
response.Write "对不起,账号或密码错误,请重新登录..."
response.End()
else
response.Write("登录成功!")
session("login")=name
session("acctid")=rs("acctid")
sql = "select BindCalled from T_BindCalled where AcctId = '" & rs("acctid") & "'"
set rs1 = CreateObject("ADODB.Recordset")
rs1.open sql,conn,1,1
session("BindCalled")=rs1("BindCalled")
rs.close
rs1.close
Set conn=nothing
response.Redirect("index.asp")
response.End()
End if
%>
这个页面用手机登陆.用session还是cookie
我是菜鸟.你改一个给我好吗.
asp 登陆cookie 保持,求助
答案:4 悬赏:10
解决时间 2021-03-23 06:38
- 提问者网友:夕夏残阳落幕
- 2021-03-22 09:33
最佳答案
- 二级知识专家网友:余生继续浪
- 2021-03-22 10:36
登录的时候:
If RememberLogin=true Then
Response.Cookies("Cookie")("key1") = UserName
Response.Cookies("Cookie")("key2") = UserPwd
Response.Cookies("Cookie").Expires = Date()+30
End If
检查权限的时候:
'读取非空Cookie自动登录
dim clUserName,clUserPwd
clUserName = Request.Cookies("Cookie")("key1")
clUserPwd = Request.Cookies("Cookie")("key2")
If Session("User")="" Then
Call Login_Cookies() '调用登录过程
End If
'登录过程
Sub Login_Cookies()
If Session("User")="" and clUserName<>"" and clUserPwd<>"" Then
登录代码,写Session值代码,与单独登录一样
End If
End Sub
If RememberLogin=true Then
Response.Cookies("Cookie")("key1") = UserName
Response.Cookies("Cookie")("key2") = UserPwd
Response.Cookies("Cookie").Expires = Date()+30
End If
检查权限的时候:
'读取非空Cookie自动登录
dim clUserName,clUserPwd
clUserName = Request.Cookies("Cookie")("key1")
clUserPwd = Request.Cookies("Cookie")("key2")
If Session("User")="" Then
Call Login_Cookies() '调用登录过程
End If
'登录过程
Sub Login_Cookies()
If Session("User")="" and clUserName<>"" and clUserPwd<>"" Then
登录代码,写Session值代码,与单独登录一样
End If
End Sub
全部回答
- 1楼网友:初心未变
- 2021-03-22 13:44
无所谓 都差不多
session安全 但资源消耗大
cookies 容易被修改 但资源消耗小
- 2楼网友:一身浪痞味
- 2021-03-22 13:22
用户登陆的时候写一个保存登陆时间的cooike到客户端就行了。
httpcookie cookie = new httpcookie("logintime");
cookie.value = datetime.now.tostring();//将服务器当前时间保存到cooike
cookie.expires = datetime.now.adddays(365);//cooike保存一年
response.cookies.add(cookie);//写入浏览器
读cooike:
httpcookie cookie = request.cookies["logintime"];
//cookie.value 这个就是你之前保存的登陆时间
//如果用户浏览器清理了cooike,你保存的东东可就获取不到喽~
一般情况下用户登陆时间是保存到数据库中的,这样能利用这个信息统计出用户的活跃度等。
- 3楼网友:浪者不回头
- 2021-03-22 11:50
你目前是session
改成cookie吧。
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯