如何完全清除会话,使用户注销后无法返回? [英] How to clear session completely , so user can not return back after logout?
问题描述
专家,
在asp.net网站上,我使用了母版页,在其中我为注销选项设置了一个按钮.
在母版页加载事件中,我为按钮文本(登录或注销)编写以下代码.
Hi Expert,
In asp.net website i have use masterpage where i put one button for logout option.
On master page load event i write following code for button text(login or logout).
if (Session["session_log_id"] == null)
{
lblUserName.Text = "";
buttLogin.Text = "Login";
}
else
{
lblUserName.Text = "<font color=#666666 size=2 face=Arial, Helvetica, sans-serif>Hi </font> , <font color=#822228 size=2 face=Arial, Helvetica, sans-serif>" + Session["session_logged_username"].ToString() + "</font>";
buttLogin.Text = "Logout";
}
在该按钮的onclick事件上,我编写代码
On that buttons onclick event,i write code
Session.RemoveAll()
并将用户重定向到首页.
到此为止对我来说一切正常.但是之后,当我按下返回"按钮时,它将返回到该页面并再次显示注销按钮.
在每个页面加载事件中,我都编写了类似这样的代码来检查Wheather会话是否存在并防止未登录的用户.
and redirect the user to Home page.
Upto this working fine for me.But after that when i hit back button it return to that page and show logout button again.
on each page load event i have write code like this to check wheather session is exist or not and prevent the unlogged user.
if (Session["session_log_id"] == null)
{
lblUserName.Text = "";
buttLogin.Text = "Login";
}
else
{
lblUserName.Text = "<font color=#666666 size=2 face=Arial, Helvetica, sans-serif>Hi </font> , <font color=#822228 size=2 face=Arial, Helvetica, sans-serif>" + Session["session_logged_username"].ToString() + "</font>";
buttLogin.Text = "Logout";
}
如何完全清除会话,以使用户注销后无法返回?
在此先感谢...
How to clear session completely , so user can not return back after logout?
Thanks in advance......
推荐答案
使用 ^ ]
与google友好,经常使用它,
为了您的解决方案,尝试使用Session.Abondon
be friendly with google , use it frequently ,
for ur solution sake try by using Session.Abondon
这个问题已经问了很多遍了.我们有一篇文章(或技巧/窍门)解释了如何解决此问题.这里的关键是禁用缓存.
这是Google搜索链接-"=" /a>].开始输入文字,Google也会建议您使搜索更加轻松.
您也可以使用Code Project搜索来找到类似的问题和文章.
The question has been asked many a times. We have an article (or tip/trick) explaining how this can be taken care of. The key thing here is disabling cache.
Here is the Google search link - logout back button asp net[^]. Start typing and Google will suggest you too to make your search even easier.
You may also use Code Project search to find the similar questions and articles.
这篇关于如何完全清除会话,使用户注销后无法返回?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!