Click here to Skip to main content
16,016,501 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a simple asp.net core application I am using cookies as authentication scheme Now I wanted to logout existing logged in users when someone elese from antoher device tried to login I want to logout the previous user I am not using identity , but I am using authentication scheme as cookies , I have table in which i log (userid,ipaddress,time)
I am using builder.Services.ConfigureApplicationCookie and setting cookie name with options,and I have added AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
I am recording every userid in table when he login with (userid,time) How to logout existing user when someone else logged in with same user .
when I login from another browser and and check httpcontext.request.cookies there are three cookies available two for aspnetcore.antiforgery and one for aspnetcore.mvc.cookie tempdataprovider

What I have tried:

I have tried everything comes from internet but it did not work I am not able to identify the existing Logged In user so that I should log it out.
Posted

1 solution

You need to manage the user state for each session on the server. Logging in from different devices will have different sessions. How you manage the user across section depends on your implementation.

A quick Google search turns up many solutions: asp.net core single user active and log out other sessions[^] - pick one that meets your specific needs.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900