jComponent has fully implemented a manipulation with browser cookies
.
COOKIES;
// Is a global variable defined in "window" scope
All registered methods:
COOKIES.get()
Method reads a cookie value.
COOKIES.get(name);
// @name {String}
// return {String}
console.log(COOKIES.get('_ga')); // "GA1.2.1821453628.1477027187"
console.log(COOKIES.get('aaa')); // ""
COOKIES.set()
Method sets a cookie value.
COOKIES.set(name, value, expire, [samesite]);
// @name {String}
// @value {String}
// @expire {String/Date/Number}
// @samesite {String} +v17, optional, can contain "lax" or "strict" (default: empty)
// return {String}
COOKIES.set('__user', 'YOUR_VALUE', '5 days');
COOKIES.rem()
Method removes a cookie.
COOKIES.rem(name);
// @name {String}
// return undefined
COOKIES.rem('__user');