js和cookie登陆验证
这是在截取的登陆功能代码
count = document.cookie.split(';')[0];//以分号为分隔符对cookie进行分割alert(document.cookie.split(';')[0]);取出--count=3
if(count.split('=')[1] >= 3){//alert(document.cookie.split('=')[1]);取出--3;PHPSESSID
alert('因为您的非法操作,您将无法再执行登录操作');
return false;
}
$('regimg').style.visibility = "visible";
url = 'login_chk.php?act='+(Math.random())+'&name='+$('lgname').value+'&pwd='+$('lgpwd').value;
xmlhttp = new XMLHttpRequest();
xmlhttp.open('get',url,true);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4&& xmlhttp.status == 200){
msg = xmlhttp.responseText;
//msg即是login_chk.php里面的reback???
if(msg == '0'){
alert('您还没有激活,请先登录邮箱进行激活操作。');
}else if(msg == '1'){
alert('用户名或密码输入错误,您还有2次机会');
$('lgpwd').select();
}else if(msg == '2'){
alert('用户名或密码输入错误,您还有1次机会');
$('lgpwd').select();
}else if(msg == '3'){
alert('因为登录次数过多,您的帐号已被冻结,请联系管理员');
$('lgname').select();
}else if(msg == '4'){
alert('用户名输入错误');
$('lgname').select();
}else if(msg == '-1'){
alert('登录成功');
location = 'main.php';
}else{
alert(msg);
}
$('regimg').style.visibility = "hidden";
}
}
xmlhttp.send(null);
}
这是处理数据的代码
count = document.cookie.split(';')[0];//以分号为分隔符对cookie进行分割alert(document.cookie.split(';')[0]);取出--count=3
if(count.split('=')[1] >= 3){//alert(document.cookie.split('=')[1]);取出--3;PHPSESSID
alert('因为您的非法操作,您将无法再执行登录操作');
return false;
}
$('regimg').style.visibility = "visible";
url = 'login_chk.php?act='+(Math.random())+'&name='+$('lgname').value+'&pwd='+$('lgpwd').value;
xmlhttp = new XMLHttpRequest();
xmlhttp.open('get',url,true);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4&& xmlhttp.status == 200){
msg = xmlhttp.responseText;
//msg即是login_chk.php里面的reback???
if(msg == '0'){
alert('您还没有激活,请先登录邮箱进行激活操作。');
}else if(msg == '1'){
alert('用户名或密码输入错误,您还有2次机会');
$('lgpwd').select();
}else if(msg == '2'){
alert('用户名或密码输入错误,您还有1次机会');
$('lgpwd').select();
}else if(msg == '3'){
alert('因为登录次数过多,您的帐号已被冻结,请联系管理员');
$('lgname').select();
}else if(msg == '4'){
alert('用户名输入错误');
$('lgname').select();
}else if(msg == '-1'){
alert('登录成功');
location = 'main.php';
}else{
alert(msg);
}
$('regimg').style.visibility = "hidden";
}
}
xmlhttp.send(null);
}

浙公网安备 33010602011771号