DOTNET Advanced Programming QQ Group 5461477
This article is sorted out how the 9CBS Forum prevents control clients from repeating the login system with the same account.
Solution: Maintain an online table, check with logins, will not log in again, as a sessionID as a unique identifier symbol, can also generate a GUID to cookie, distinguish between different clients, then JS, can achieve better The effect, such as automatically offline the code after departure:
Public Virtual Void Application_Start (Object Sender, Eventargs E) {// Reset The Mailer IndicatorApplication ["Mailerstatus"] = "all mailings completion";
// initialize a datatable for users onlineDataTable 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 ["useertable"] = objusertable;} ///
/// The session_start event address us /// Application ["useertable"]. ///
Public Virtual Void Session_Start (Object Sender, Eventargs E)
{
Application.lock ();
//Application.lock ();
DataTable objusertable = (dataable) Application ["useertable"];
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 ["" "= objusertable;
Application.unlock ();
}
///
/////// Application ["useertable"] ./// PUBLIC Virtual Void Session_end (Object Sender, Eventargs E)
{
Application.lock ();
DataTable objusertable = (dataable) Application ["useertable"];
Objusertable.Rows.Find ((GUID) Session ["PfSessionID"]). delete ();
Application ["" "= objusertable;
Application.unlock ();
}