下次自己主动登录(记住password)功能

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'));
    });
原文地址:https://www.cnblogs.com/yjbjingcha/p/7100291.html