Skip to content
🎉 locally-cookie is a 1KB lightweight library base localStorage that looks like cookie.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build
src
.babelrc
.gitignore
.npmignore
LICENSE
README.md
README.zh-CN.md
package.json

README.md

English | 简体中文

locally-cookie is a 1KB lightweight library based on localStorage that stores session data and fixed time-length data locally

Getting Started

  • Storage is only valid in subdomains
  • across domains it is not recommended to store large amounts of data, such as the cache of the entire page
  • support IE8 or more

Installation

npm i -S locally-cookie

API

import locallyCookie from 'locally-cookie';

set

/**
 * Parameter
 * key {String} required
 * value {String|Boolean|Number|Array|Object} required
 * day {Number} 0 session data, Turn off browser invalidation
 | 1,2... Expired after 1, 2 days | -1 Theory is permanent and effective, optional, default 0
*/
locallyCookie.set('key', value, [day]);

get

/**
 * Parameter
 * key {String} required
*/
locallyCookie.get('key');

delete

/**
 * Parameter
 * key {String} required
*/
locallyCookie.del('key');

has

/**
 * Parameter
 * key {String} required
*/
locallyCookie.has('key');
You can’t perform that action at this time.