js文件:jquery.cookie.js
js code:
1. $.cookie(‘the_cookie’); // 读取 cookie
4. $.cookie(‘the_cookie’, 'the_value’); // 存储 cookie
5. $.cookie(‘the_cookie’, 'the_value’, { expires: 7 }); // 存储一个带7天期限cookie
6. $.cookie(‘the_cookie’, '', { expires: -1 }); // 删除 cookie
eg: var the_cookie='username';
if($.cookie(the_cookie)){ //说明cookie存的值不为null
$('#username').val(the_cookie); //错误
$('#username').val($.cookie(the_cookie)); //之前犯的低级错误.怎么能将定死的变量放到这里面来.是错误的.必须得从cookie里面取值,才是正确的值.
$('#remuser').attr("checked","checked");
}
$('#btn_login').click(function(){
var userName=$('#username').val();
if($('#remuser').attr('checked')){
alert("ss");
$.cookie(the_cookie,userName,{ path: '/',expires:30});
}else{
$.cookie(the_cookie,null,{ path: '/',expires:0});
}
});