Skip to content

fcordillot/cookie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@fcordillot/cookie npm GitHub file size in bytes Build Status

A simple Cookie manager in JavaScript

Installation

ES5

<script src="https://cdn.jsdelivr.net/npm/@fcordillot/cookie"></script>

NPM

$ npm i @fcordillot/cookie
import Cookie from '@fcordillot/cookie'

Usage

import Cookie from '@fcordillot/cookie'

Cookie.setCookie('myCookie', 'Hello World!')

// Optionnaly you can set a duration in days
// Default duration is 365 days (1 year)
Cookie.setCookie('myCookie', 'Hello World!', 12) // will expire in 12 days
Cookie.setCookie('myCookie', 'Hello World!', 1 / 24) // will expire in 1 hour

const cookie = Cookie.getCookie('myCookie') // Returns "Hello World!"