How to prevent the same account from repeatedly logging on to the system

Source: Internet
Author: User
How to prevent control clients from repeatedly logging on to the system using the same account.
Solution:
Maintain an online table. If you have logged on to the table, you cannot log on again. If you use sessionid as the unique identifier, you can also generate a GUID and send it to the COOKIE to distinguish different clients, and then use JS, can achieve better results, such as automatically offline after leaving
Solution code:
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 ();
}

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.