A ponyfill to allow use of the Cookie Store API in modern browsers that don't support it natively, including IE11. Also compatible with TypeScript.
To ensure the most up-to-date compatibility with browsers, we recommend that you install version 4 of the package with the next
flag:
npm install cookie-store@next
// import polyfill and declare types
import { cookieStore } from 'cookie-store';
// set a cookie
await cookieStore.set('forgive', 'me');
// get a cookie
const foo = await cookieStore.get('forgive');
console.log(foo); // { name: 'forgive', value: 'me' }
// set another cookie
await cookieStore.set('forget', 'it');
// get multiple cookies
const cookies = await cookieStore.getAll();
console.log(cookies); // [{ name: 'forgive', value: 'me' }, { name: 'forget', value: 'it' }]
// delete a cookie
await cookieStore.delete('forget');
Before running tests, you'll need to add the following entry to your /etc/hosts
file on your machine:
127.0.0.1 foo.bar.localhost
Then run npm test