开发者

Can we end other user's Session?

开发者 https://www.devze.com 2023-03-22 23:18 出处:网络
I have a Admin and I want to give a feature where Admin can end other user\'s session. Is this really possible? I know sessions are stored individually and normally nobody would do what I want but is

I have a Admin and I want to give a feature where Admin can end other user's session. Is this really possible? I know sessions are stored individually and normally nobody would do what I want but is this really possible? If yes, then how?

Thanks in advance :开发者_开发技巧)


You could use the Admin session to write a boolean variabile (e.g. ResetSessions=true) in the Application context, that each User session would read and call a Reset method if necessary.

// Admin
Application["ResetSessions"] = true;

// User
if (Convert.ToBoolean(Application["ResetSessions"]))
{
   ... reset session ...
}


You could create a ApplicationSession which hold a list of UserId's, every time the user loads a page check if the userId is in that list, if they are then logged them out.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号