locked
Session.Abandon() can't logout RRS feed

  • Question

  • User-11139454 posted
    I use the Login controls of Asp.net 2.0 in my program.
    I want to logout a user by program, I try Session.Abandon() for this.
    But I found that the user is the same after I execute Session.Abandon().

    I thought that Session.Abandon()  will break the connection of current user,
    but I fail

    How can I logout a user by program?
    Thursday, November 3, 2005 9:13 AM

All replies

  • User961349301 posted
    The Login control will by default use the Membership feature and FormsAuthentication. FormsAuthetnication will create a cookie. This cookie is used to know if the user is still logged in, so it doesn't depend on the Session. You can use the SignOut method of the FormsAuthentication to logout the user.
    Thursday, November 3, 2005 9:59 AM
  • User-11139454 posted
    Thanks,
    Your answer really do me a favor!

    I still have questions about login controls.

    How can we know how may user have login?
    How to list the users on line?
    Thursday, November 3, 2005 4:28 PM
  • User961349301 posted

    You can use the IsAuthenticated property to see if a user is online:

    Context.User.Identity.IsAuthenticated

    If you use the Membership feature you can get all the users an iterate through the MembershipUsers and see if the IsOnline property of the MembershipUser class is true:

    foreach(MembershipUser user in Membership.GetAllUsers())
    {
        if (user.IsOnline)
            //....
    }

    Thursday, November 3, 2005 4:46 PM
  • User-11139454 posted
    Thanks,
    But my user accounts is stored in another machine's SqlServer.
    Can I use Membership.GetAllUsers to get the user accounts?
    Thursday, November 3, 2005 10:19 PM
  • User961349301 posted

    Only if you build a MembershipProvider that will go against your data source.

    The Login control etc shipped with ASP.Net 2.0 uses by default the Membership feature. So take a look at it if you don't already have done it.

    If you don't want or build your own provider, you still have to implement logic to know which users are online. There is no default feature shipped within the box that can help you as long as you don't use the Microsoft default Membership providers.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    <o:p> </o:p>

    <o:p> </o:p>

    Friday, November 4, 2005 12:08 AM