`

模拟单点登录方式

阅读更多

判断单点登录的一种方式

利用js的定时器,去定时执行ajax请求来获取用户的状态,然后根据用户的状态完成是否用户已经登录,在完成其他的业务操作。

//用户是否与其它地登录定时器
function loginOneUserInterval(){
if(intervalFlag == false){
//10分后向服务器请求
setInterval("loginOneUserLimite()",600000);
intervalFlag = true;
}
}
//用户是否与其它地登录定时器,发送http异步请求
function loginOneUserLimite(){
$.ajax({
url : importAction+"cus/cuslimit!isUserLogined.action",
type : "post",
dataType : "json",
success : function(json){
if( typeof(json.returnMessage) == "undefined"|| json.returnMessage == null || json.returnMessage != "success"){
if(isIOS()){
player.stop();
}else{
oSwf.JsStopVideo();
}
alert("您的账户在其它计算机登录,请及时修改密码!");
window.close();
}
},
error : function(error) {
}});
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics