@trendyol-js/cookie-helper
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

cookie-helper

simple cookie helper that provides functions to CRUD cookies

npm i @trendyol-js/cookie-helper

create cookie

createCookie function will create cookie as specified.

const key = 'userId';
const value = '1234';
createCookie(key, value);

to specify a expiration date, you can pass number of days as last parameter.

const key = 'userId';
const value = '1234';
const days = 3; // number of days that the cookie will be valid
createCookie(key, value, days);

get cookies as object

getCookiesObject function will return object which contains cookies;

const cookies = getCookiesObject();

get cookie

readCookie function will return the value of a given cookie name

const value = readCookie('useId');

delete cookie

deleteCookie function will invalidate the cookie with given name as parameter

deleteCookie('useId');

How To Build

npm install

npm run build

How To Test

npm run test

Readme

Keywords

Package Sidebar

Install

npm i @trendyol-js/cookie-helper

Weekly Downloads

56

Version

1.0.5

License

MIT

Unpacked Size

3.4 kB

Total Files

4

Last publish

Collaborators

  • trendyol-js