System.Web.Security.FormsAuthentication.SetAuthCookie(username, false);这是微软自有的,应该能满足你的要求

解决方案 »

  1.   

    在Globe里public static ArrayList sessionList = ArrayList.Synchronized( new ArrayList() );protected void Session_Start(Object sender, EventArgs e)
    {
    sessionList.Add( Session );
    }protected void Session_End(Object sender, EventArgs e)
    {
    sessionList.Remove( Session );
    }对用户的控制(包括window.onunload时弹开的网页)都通过这个List,或者你在Session_End里对库操作
      

  2.   

    在运行Session_End(Object sender, EventArgs e)的时候这个Session里的值还能取到吗
      

  3.   

    我能直接这样用吗
    protected void Session_End(Object sender, EventArgs e)
    {
    int userid = Session["userid"];
             sql = "delete useronline where userid = "+ userid 
    .......}
    请各位大侠提示一下嘛,呵呵,(已经提示了???!!!!)
      

  4.   

    在数据库中新建一个字段(char(24)即可),将Session的SessionID保存在该字段,SessionID是一个24位的GUID字符串,任何两个Session的SessionID都不会相同,当用户第一次访问时,在global.asax的Session_Start方法中将该SessionID存入数据库,若用户登录,可根据该SessionID来将其登录名加入数据库("update 在线用户表 set 用户名='当前登录的用户名' where SessionID='"+Session.SessionID+"'" ),当Session超时时,在Session_End事件中根据当前的SessionID值删除对应的在线用户记录("delete from 在线用户表 where SessionID='"+Session.SessionID+"'")。因为用户关闭浏览器并不会立即销毁Session,所以无法实时精确地获取当前的在线用户信息。
      

  5.   

    >>>在运行Session_End(Object sender, EventArgs e)的时候这个Session里的值还能取到吗yes (you are just lazy, you can just try it and know if it is true)or look into a similar schemes in ASP:Active User Count Without Global.asa
    http://www.aspfree.com/examples/1908,1/examples.aspx