下次自动登录(记住密码)效能
下次自动登录(记住密码)功能
1:进入cookie插件
<script src="jquery.cookie.js" type="text/javascript"></script>
2:登录界面
<input type="checkbox" id="autologin" /><label for="autologin">下次自动登录</label>
:3:登录方法:如果登录成功的话
//如果选择:记住密码
var chk = $('#autologin')[0].checked;
if (chk) {
$.cookie('autologin', chk, {expires: 7});
$.cookie('username', $('#username').val(), {expires: 7});
$.cookie('password', $('#password').val(), {expires: 7});
}else {
//如果没有选择;记住密码
$.cookie('autologin', chk);
$.cookie('username', $('#username').val());
$.cookie('password', $('#password').val());
}
4:登录界面初始化
$(document).ready(function() {
$('#autologin')[0].checked = $.cookie('autologin');
$('#username').val($.cookie('username'));
$('#password').val($.cookie('password'));
});
版权声明:本文为博主原创文章,未经博主允许不得转载。