1.1.1 • Published 6 years ago
i-cookie v1.1.1
i-cookie
A simple, lightweight JavaScript API for handling browser cookies
Getting started
run npm:
npm i i-cookie --save
and then:
import iCookie from 'i-cookie'
Write a cookie
A cookie is set with a simple object as the first parameter:
/**
* @param {key}
* @param {value}
* @param {option} set the `expires` 【non-mandatory】
*/
iCookie.cookie("CookieKey", CookieValue, {expires: Date});
The set Date
demo:
var curDate = new Date();
curDate.setTime(curDate.getTime() + (1 * 60 * 1000)); //set 1 minute expire
Read a cookie
iCookie.cookie("CookieKey")
Delete a cookie
iCookie.deleteCookie("CookieKey")