# Cookies

[![+Professional Support](https://www.totaljs.com/img/badge-support.svg)](https://www.totaljs.com/support/) [![+Chat with contributors](https://www.totaljs.com/img/badge-chat.svg)](https://messenger.totaljs.com)

jComponent has fully implemented a manipulation with browser `cookies`.

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

__All registered methods:__

- [`COOKIES.get(name)`](#method-cookies-get-)
- [`COOKIES.set(name, value, expire, [samesite])`](#method-cookies-set-)
- [`COOKIES.rem(name)`](#method-cookies-rem-)

---

### Method: `COOKIES.get()`

Method reads a cookie value.

```javascript
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.

```javascript
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.

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

COOKIES.rem('__user');
```