C#
After the user logs on successfully, the user name is stored in the MySession key value pair
idictionary<string, object> mysession = new dictionary<string, object> ();
Mysession.add (Basecontroller.checklogin, data.username);
After the storage is complete, the foreground page ()
Checklogin (); First check whether landing setinterval (checklogin,30000); Check every 30 seconds for login//Verify login Status function Checklogin () { $.post (' Checklogin ', function (data) {if (data.state== "1") { location.href= "Login";}});
Background Checklogin method
[HttpPost] Public ActionResult Checklogin () { try { Object obj = Mysession.containskey ( Basecontroller.checklogin); if (obj = = null) { return Content (fail); } else { return Content (Success); } } catch (Exception) { return Content (fail); } }
This makes it possible to roughly implement cross-domain access (as long as all pages call the JS method) and check the login function regularly.
Determine if the user is logged in (Jump to the login screen without logging in)