0.1.1 • Published 2 years ago

butter-cookie v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

🍪 Butter Cookie

Manipulate cookie easily via Proxy, less than 1KB after gzip.

🔧 Usage

First of all, you should install this package via npm or other package manager you're using.

npm install butter-cookie

Then use it like this:

import Cookie from 'butter-cookie';

// To get the value of some key from document.cookie
// For example, you want to get the value of key named "username"

console.log(Cookie.username);

// To set a new value to cookie
Cookie.username = 'new_user';

// To set a new value to cookie with expires or other attributes
Cookie.username = {
  sameSite: 'lax',
  expires: '1h',
  value: 'new_user',
};

// To remove a key from cookie
delete Cookie.username;

// To remove a key from certain domain and path
Cookie.username = {
  expires: '-1',
  domain: 'github.com',
  path: '/backrunner',
};

✒ License

MIT