如何决定是否将登录内容保存到Cookie里?
login.htm
<% @ language=javascript %>
<%
if (request.cookies("savedlogin").haskeys) {
response.redirect("checklogin.asp?cookie=1")
}
%>
<html>
<head>
<title>精彩春风之登录页面</title>
</head>
<body>
我要登录随风起舞
<form action="checklogin.asp" method="post">
电子邮件: <input type="text" name="email" size="40"><br>
口令: <input type="password" name="password" size="40"><p>
<input type="checkbox" name="savelogin"> 要把登录内容存为cookie吗?<p>
<input type="submit" value="登录"><input type="reset">
</form>
checklogin.asp
<%
dim stremail
if request.querystring("cookie") = 1 then
stremail = request.cookies("savedlogin")("email")
else
stremail = request.form("email")
end if
dim bloginsaved
if request.form("savelogin") = "on" then
response.cookies("savedlogin")("email") = request("email")
response.cookies("savedlogin")("pw") = request("password")
response.cookies("savedlogin").expires = date + 30
bloginsaved = true
else
bloginsaved = false
end if
%>
<html>
<head>
<title>精彩春风之登录验证</title>
</head>
<body>
<% if bloginsaved then %>
将登录信息保存到cookie里去<hr>
<% end if %>
欢迎光临随风起舞!<p>
<% if request.querystring("cookie") = 1 then %>
保存成功!<p>
<% end if %>
请确认您的电子邮件: <% = stremail %>
</body></html>
下一篇: 如何获知所有的Cookie?