ASP.Net authentication for all sessions

How do you write out all sessions with an ASP.NET identifier? Suppose you are logged in from two different browsers with the same user. When a user signs up from one browser, the session of the other browser must also be invalid. (I need this to block all user sessions when changing the password.)

You can display the current session with the ASP.Net ID with the following code.

var AutheticationManager = HttpContext.GetOwinContext().Authentication; AuthenticationManager.SignOut(); 

This will not go beyond all user sessions.

Edit: An idea with a session was a good starting point. I solved the problem and wrote a message in case you have the same problem.

+2
source share
1 answer

This can be done by adding a newly created session from the Global.asax list to the list.

Iterate then to compare user and SignOut user sessions.

 protected void Session_Start(object sender, EventArgs e) { MyGlobalObject.Sessions.Add(HttpContext.GetOwinContext().Authentication); } 

And later, in the checkout event:

 private void SignoutAll() { foreach (var authenticationManager in MyGlobalObject.Sessions) { authenticationManager.SignOut(); } } 
+4
source

Source: https://habr.com/ru/post/1210548/


All Articles