单击注销时登录状态未清除会话 [英] Login Status not clearing session when click logout

查看:109
本文介绍了单击注销时登录状态未清除会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.

我正在开发一个Web应用程序,其中一项要求是间隔15分钟后自动注销用户.我在我的web.config中设置了

Hi.

I''m developing a web application, where one of the requirement is to automaticly logout user after 15 mins interval. I set this in my web.config

<forms loginUrl="Login.aspx" timeout="15"/>   



15分钟后,用户将自动注销(登录页面).

我有一个清单可以显示哪些用户在线.但是即使用户单击注销按钮(使用登录状态),该用户也将在用户登录后显示,并且将保持在线状态15分钟.播种时间仍在进行中.

单击注销按钮时,我想清除会话时间.意味着现在会话将在15分钟后超时,但是当我单击注销按钮时,我希望会话在那15分钟之前结束.

我尝试使用这些代码结束超时;



where user will be automatically logout (to login page) after 15 minutes.

I have a listing to show which users is online.But this users will be shown when user is logged in and will remain as online for 15 minutes eventhough user click logout button (using login status).It seems like the when i click logout, the seesion time is still ongoing.

I want to clear the session time when i click the logout button. Means now session will timeout after 15 minutes,but when i click the logout button,i want the session to be ended before that 15 minutes.

I tried using these codes to end the timeout ;

Session.Clear();
Session.Abandon();
Session.RemoveAll();
FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();
Roles.DeleteCookie();



但似乎没有任何效果.超时只会在15分钟后结束.
我在LoginStatus1_LoggedOut和/或LoginStatus1_LoggingOut的情况下使用过,但是我无法弄清为什么它不起作用.

有人可以帮我吗?有什么想法/建议吗?



but nothing is seems to be working.The timeout will only end after the 15 minutes.
I used in the event of LoginStatus1_LoggedOut and/or LoginStatus1_LoggingOut, but i cant figure out why its not working.

Can anyone help me on this?Any ideas/suggestion guys?

推荐答案

好像我也必须清除缓存;

Looks like i have to clear the cache as well ;

string sKey = (string)Session["user"];
        string sUser = Convert.ToString(Cache[sKey]);
        Cache.Remove(sUser);




按照上述方法在Global.asax文件中提及您的所有资料

Hi ,

Mention Your All Stuff in Global.asax file in following method as mentioned

public void Session_End(object s, EventArgs e)
{
     Session.Clear(); 
        Session.Abandon();
        Session.RemoveAll();
        FormsAuthentication.SignOut();
        FormsAuthentication.RedirectToLoginPage();
        Roles.DeleteCookie();
}



Put it under Page_Load

public void Page_Load(object sender, EventArgs e)
{

Session.Clear();
Session.Abandon();
Session.RemoveAll();
FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();
Roles.DeleteCookie();



}


这篇关于单击注销时登录状态未清除会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆