Skip to content

simple cookie helper that provides functions to CRUD cookies

Notifications You must be signed in to change notification settings

mehmetsefabalik/cookie-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cookie-helper

simple cookie helper that provides functions to CRUD cookies

npm i @mehmetsefabalik/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

About

simple cookie helper that provides functions to CRUD cookies

Resources

Stars

Watchers

Forks