如何在用户点击“退出”按钮的时候清空Session("UserName")?
登录页面index.asp,
如果登录成功,用如下语句:
Session("UserName")=trim(request.form("Name"))
response.redirect "work.asp"
work.asp的内容如下:
========================================
<html>
<body>
<%
if Session("UserName")="" then
response.write "您还没有登录,<a href=""index.asp"">点击这里</a>进入登录网页。"
response.flush
response.end
end if
%>
<%=Session("UserName")%></font>,您好!
<input type="button" value="注销" onClick="JavaScript:window.document.location.href='logout.asp'">
</body>
</html>
=================================================
'logout.asp'内容如下:
=================================================
<%
Session("UserName")=""
response.redirect "index.asp"
%>
=================================================
结果退出之后,用户不登陆就能浏览work.asp。
如何解决这个问题呢?请帮忙。谢谢!