简体   繁体   中英

how to kill a session that it exist

A user loged in site before. from another browser a user with same "UserName" logs in. Now I want to log out older user and replace new user. I can Recognize that a session with same "UserName" loged in, but I don't know how to kill it's session. Help me please.

As far as I understand your requirement, I think you want that two users with same username can't be logged in your application, and If your it happens then the user who logged in after the another one should continue and the older one get logged out.

For such requirement, you can generate the Session Key for each user who logged into the application and save it and check this value on each request. For this you can use Application.BeginRequest handler.

So basically what you are doing is generating the SessionKey for each login. So when another user logged in with same credential, you will generate the session key and after any request you will match this sessionKey against the currently saved session key for this username. if it is match then OK otherwise logged out this user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM