cookie.js插件的案例:

  https://github.com/jaywcjlove/cookie.js/blob/master/README.md    文档  api   在这里即可查看用法

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

  <!DOCTYPE html>
  <html>
    <head>
      <meta charset="UTF-8">
      <title></title>
      <script src="../js/cookie.js"></script>
    </head>
    <body>
      名字:<input type="text" name="name" id="name" /><br />
      密码:<input type="text" name="pass" id="pass" /><br />
      <button id="cun">存cookie</button><br />
      <button id="huo">获cookie</button><br />
      <button id="shan">删cookie</button><br />
    </body>
  </html>
  <script>
    function $(id){
      return document.getElementById(id);
    }
    $("cun").onclick=function(){
      var uname=$("name").value;
      var pass=$("pass").value;
      cookie('name',uname,1);
      cookie('pass',pass,1);
    }
    $("huo").onclick=function(){
      alert(document.cookie);
    }
    $("shan").onclick=function(){
      cookie.clear()
    }
  </script>

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄