用户注销时如何清除会话? [英] How to clear session when user log out?
本文介绍了用户注销时如何清除会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
授权会员仅查看我网站的详细信息。如果成员单击注销按钮,则表示必须将其重定向到主页(Home.aspx)。这是正常的。再次成员想要查看他们可以访问页面的特定方式..所以这是我的错误..只能帮助我,如何清除会话?
Authorized member only view details of my site. If member click a log out button means they have to be redirected to home page(Home.aspx). This is works correctly. Again member want to view the particular means they can access a page.. So this s my error.. can only help me, how to clear the session??
if (IsPostBack == false)
{
if (Session["log"] != null)
{
if (Session["log"].ToString() == "s")
{
//function()
}
else
{
Response.Redirect("UserLogin.aspx", false);
}
}
else
{
Response.Redirect("UserLogin.aspx", false);
}
}
推荐答案
在这里查看:
http://forums.asp.net/t /1366105.aspx/1 [ ^ ]
http: //stackoverflow.com/questions/345157/asp-net-how-to-clear-out-session-on-log-out [ ^ ]
注销后清除会话 [ ^ ]
http://stackoverflow.com/questions/347377/in-asp-net-when-should-i-use-session-clear - 而不是会话放弃 [ ^ ]
Hi,
Have a look here:
http://forums.asp.net/t/1366105.aspx/1[^]
http://stackoverflow.com/questions/345157/asp-net-how-to-clear-out-session-on-log-out[^]
Clearing session after logout[^]
http://stackoverflow.com/questions/347377/in-asp-net-when-should-i-use-session-clear-rather-than-session-abandon[^]
尝试使用它。
try to use this.
session.clear();
session.abandon();
为了清除会话值,您可以使用以下
For clearing the session values, you can use the following
session.clear();
session.abandon();
和页面加载检查
的值
and on page load check the value of the
if(session["uid"]==null)
{
//redirect page
}
谢谢
Thanks
这篇关于用户注销时如何清除会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文