jComponent / Helpers / Cookies
Updated: 27. January 2019
Author: Peter Širka

Cookies

Professional Support Chat with contributors

jComponent has fully implemented a manipulation with browser cookies.

COOKIES;
// Is a global variable defined in "window" scope

All registered methods:


Method: 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'));  // ""

Method: 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');

Method: COOKIES.rem()

Method removes a cookie.

COOKIES.rem(name);
// @name {String}
// return undefined

COOKIES.rem('__user');