A simple, lightweight JavaScript API for handling browser cookies
run npm:
npm i i-cookie --save
and then:
import iCookie from 'i-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
iCookie.cookie("CookieKey")
iCookie.deleteCookie("CookieKey")