All files / addon/utils cookiesmanager.js

93.75% Statements 15/16
100% Branches 4/4
100% Functions 3/3
93.75% Lines 15/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32    2x 2x 1x 1x 1x   2x       3x 3x 3x 3x 3x     3x 1x     2x       1x        
export default {
  createCookie: function (name, value, days) {
      let expires = "";
      if (days) {
          let date = new Date();
          date.setTime(date.getTime()+(days*24*60*60*1000));
          expires = "; expires="+date.toGMTString();
      }
      document.cookie = name+"="+value+expires+"; path=/; secure";
  },
 
  getCookie: function (name) {
      let nameEQ = name + "=";
      let ca = document.cookie.split(';');
      for(let elem of ca) {
          let c = elem;
          while (c.charAt(0)===' ') {
              c = c.substring(1,c.length);
          }
          if (c.indexOf(nameEQ) === 0) {
              return c.substring(nameEQ.length,c.length);
          }
      }
      return null;
  },
 
  deleteCookie: function (name) {
      this.createCookie(name,"",-1);
  }
 
};