Maintain an Online table and check whether there is a logon. You are not allowed to log on again. You can use Sessionid as the unique identifier. You can also generate a GUID and send it to the COOKIE to distinguish different clients, and add JS, it can achieve better results, such as automatic offline after leaving.
The solution code is as follows:
Public virtual void Application_Start (object sender, EventArgs e)
{
// Reset the mailer indicator
Application ["MailerStatus"] = "All Mailings Complete ";
// Initialize a datatable for users online
DataTable objUserTable = new DataTable ();
ObjUserTable. Columns. Add ("SessionID", System. Type. GetType ("System. Guid "));
ObjUserTable. Columns. Add ("PeopleID", System. Type. GetType ("System. Int32 "));
ObjUserTable. Columns. Add ("ShowDetail", System. Type. GetType ("System. Boolean "));
DataColumn [] pk = new DataColumn [1];
Pk [0] = objUserTable. Columns [0];
ObjUserTable. PrimaryKey = pk;
Application ["UserTable"] = objUserTable;
}
/**////
/// The Session_Start event adds user session information
/// Application ["UserTable"].
///
Public virtual void Session_Start (object sender, EventArgs e)
{
Application. Lock ();
// Application. Lock ();
DataTable objUserTable = (DataTable) Application ["UserTable"];
DataRow objRow = objUserTable. NewRow ();
Guid objGuid = Guid. NewGuid ();
ObjRow [0] = objGuid;
Session ["PfSessionID"] = objRow [0];
ObjRow [1] = 0;
ObjRow [2] = false;
ObjUserTable. Rows. Add (objRow );
Application ["UserTable"] = objUserTable;
Application. UnLock ();
}
/**////
/// The Session_End event deletes user session information from
/// Application ["UserTable"].
///
Public virtual void Session_End (object sender, EventArgs e)
{
Application. Lock ();
DataTable objUserTable = (DataTable) Application ["UserTable"];
ObjUserTable. Rows. Find (Guid) Session ["PfSessionID"]). Delete ();
Application ["UserTable"] = objUserTable;
Application. UnLock ();
}