<%
'是提取url中变量loginout的值是否为true,若为真,就执行Session.Abandon()。
if Request.QueryString("loginout")="true" then
Session.Abandon()
end if
'只有在当点击了submit按钮的前提下,再来判断提取的东西都不为空,则建立Session对象。
submitname=request.form("submit1")
if submitname="submit" then
if Request.Form("name")<>"" and Request.Form("pwd")<>"" then
Session("name")=Request.Form("name")
Session("pw")=Request.Form("pwd")
end if
end if
%>
<%
'如果Session("name")不为空,则显示Session("name")的值,并且做一个到info.asp的链接。
if Session("name")<>"" then
response.write("你的name值是:"&Session("name"))
response.write("<br><a href='info.asp'>显示你的资料</a>")
else
'否则,即Session("name")为空不存在,则显示表单用以输入建立Session的平台。
%>
<form action="login.asp" method="post">
姓名:<input type="text" name="name"><br>
密码:<input type="password" name="pwd"><br>
<input type="submit" value="submit" name="submit1">
</form>
<!--同样做了一个到info.asp的链接。-->
<a href="info.asp">显示你的资料</a>
<%end if%>
<%
'如果session对象值为空则跳转到login.asp
if session("name")="" then
Response.Redirect("login.asp")
'否则就显示个人信息
else
Response.Write("你的姓名:"&session("name")&"<br>")
Response.Write("你的密码:"&session("pw")&"<br>")
end if
%>
<a href="login.asp">返回</a>
<a href="login.asp?loginout=true">退出</a>