forcefully log out a specific user among all online users

10,759

You cannot logout a user from outside of their session. See Programatically logout an ASP.NET user for a possible workaround.

Share:
10,759
Krishanu Dey
Author by

Krishanu Dey

Updated on June 04, 2022

Comments

  • Krishanu Dey
    Krishanu Dey almost 2 years

    In my site administrator can view list all other online users.

    Administrator can also disable any account from that list.

    Everything was going fine so far. But now I decided to log out the user which is being disabled. How can I do a log out operation for a particular user from the above specified online user list?

    NOTE: I'm using default membership schema for my SQL Server database.

  • Krishanu Dey
    Krishanu Dey about 12 years
    Thanks a lot. the above link helped me a lot. I added the following code to page_load event and it worked perfect. if (Page.User.Identity.IsAuthenticated) { MembershipUser user = Membership.GetUser(Page.User.Identity.Name); if (!user.IsApproved) { HttpContext.Current.Session.Abandon(); FormsAuthentication.SignOut(); Response.Redorect("Default.aspx"); } }