The code is as follows:
Copy Code code as follows:
///single sign-on (on)
public void Sign (string ssomethods, String p Assword)
{
//To determine the login situation here the method omits ...
int result = Checklogin (username, password);
if (result>0)
{
//unique ID, can be set by itself
string key = String. Format ("{0}_{1}", username, password);
//Gets the key value in cache
String usercache = Cache[key]. ToString ();
//To determine whether or not to be empty
if (string. IsNullOrEmpty (Usercache))
{
TimeSpan sessiontimeout = new TimeSpan (0,0,httpcontext.current.session.timeout,0 , 0);
HttpContext.Current.Cache.Insert (key,key,null,datetime.maxvalue,sessiontimeout,cacheitempriority, Notremovable,null);
session["User"] = key;
Response.Write ("<font color=red> login succeeded!) </font> ");
}
Else
{
Repsonse.write ("<font color=red>) Sorry, you have already logged in elsewhere!" </font> ");
return;
}
}
Else
{
Response.Write ("User name does not exist!") ");
}
}