Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

How to end other users session

I have a asp.net web application and this has Admin and user sections.
Admin can set permissions for the user under the application.

Now my clients needs a feature that if Admin changes anything/settings for user then if that user is logged in then end his session, so that he relogins and new settings applied to it.

I am storing user class object in the session, I need to can this be done.
0
yadavdep
Asked:
yadavdep
  • 2
  • 2
1 Solution
 
Easwaran ParamasivamCommented:
Yes. You can get the user's session by index/key and remove from the session using below code. By this way you can delete more sessions if you want by using the method multiple times or in for loop.

Session.Remove("YourKey");

Open in new window


HTH.
0
 
Carl TawnSystems and Integration DeveloperCommented:
Session.Remove doesn't kill a session, it simply removes a value from the current session.

There is no way to kill all sessions, short of recycling the app pool. Your best bet might be to use an Application variable to indicate that something has changed and a new login is required. You can then kill the current session using:
Session.Abandon();

Open in new window

0
 
Easwaran ParamasivamCommented:
Session.Abondon() will end current user session. But the requirement is that from admin session other user(s) session should be killed. If we remove the user from the session then the session won't be available to him.
0
 
Carl TawnSystems and Integration DeveloperCommented:
I'm not quite sure why you've accepted that comment as a solution. Unless I've misunderstood your requirement, it won't do what you want.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now