Skip to content

Vesal-J/cookie-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cookie Manager

In this repository, I tried to collect the functions needed to Manage cookies in javascript, hope you enjoy it

add cookie

add a single cookie

createCookie("cookieName", "Cookie value", 20)

this function takes three arguments and here is explain

  • first argument: Cookie name
  • second argument: Cookie Value
  • third argument (optional): expire time of cookie, default value is 0

add multiple cookies

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

add multiple cookies with expire time

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)

you can skip the days item in your object, and the default value is 0

remove cookies

remove a single cookie

removeCookie("cookieName")

remove all of cookie

removeAllCookies()

get cookies

get a single cookie

getSingleCookie("cookieName")

get all of cookies

getAllCookies()

other functions

check for if cookie exists

checkCookie("cookieName")

this function returns a boolean

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published