In this repository, I tried to collect the functions needed to Manage cookies in javascript, hope you enjoy it
createCookie("cookieName", "Cookie value", 20)
- first argument: Cookie name
- second argument: Cookie Value
- third argument (optional): expire time of cookie, default value is 0
let cookies = {
cookie1: "c1",
cookie2: "c2",
cookie3: "c3",
cookie4: "c6",
}
createMultipleCookies(cookies)
this function takes an object of cookies, the key will be the cookie key and value will be value of cookie.
you can use this method when you don't want to use expire time, if you need it, instead of using this, use next method
let cookie = [
{
name: "cookie1",
value: "c1",
days: 1
},
{
name: "cookie2",
value: "c2",
days: 1
},
{
name: "cookie3",
value: "c3",
days: 1
},
{
name: "cookie4",
value: "c4",
}
]
createMultipleCookiesWithExpireTime(cookie)
removeCookie("cookieName")
removeAllCookies()
getSingleCookie("cookieName")
getAllCookies()
checkCookie("cookieName")
this function returns a boolean