jquery.cookie.js的使用

jquery.cookie.js是一个基于jquery的插件

所以要加上两条引用:

使用前要先导入jquery.js

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

然后再导入jquery.cookie.js,可以使用google和百度搜索下再下载

<script type="text/javascript" src="http://yxb.qq.com/js/jquery.cookie.js"></script>

  • $.cookie('the_cookie'); // 获得cookie
  • $.cookie('the_cookie', 'the_value'); // 设置cookie
  • $.cookie('the_cookie', 'the_value', { expires: 7 }); //设置带时间的cookie天
  • $.cookie('the_cookie', '', { expires: -1 }); // 删除
  • $.cookie('the_cookie', null); // 删除 cookie
  • $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true});//新建一个cookie 包括有效期 路径 域名等
原文地址:https://www.cnblogs.com/luwei-s/p/4386620.html