Copy environment

Cookie

A simple built-in cookie utility that allows setting and getting cookies without the need of specifiyng domains or paths.

Usage

Cookie path and domain are automatically set from window.gotoAndPlay.cookieDomain and window.gotoAndPlay.cookiePath globals.

Setting cookies

Set a simple cookie:

import Cookie from '@cookie';

const name = 'cookie';
const value = 'value';
Cookie.set(name, value);

Set a cookie with custom expiration:

import Cookie from '@cookie';

const name = 'cookie';
const value = 'value';
const expireHours = 24;
Cookie.set(name, value, expireHours);

Getting cookies

Get a cookie value:

import Cookie from '@cookie';

const name = 'cookie';
const value = Cookie.get(name);