Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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');

About

🎉 locally-cookie is a 1KB lightweight library base localStorage that looks like cookie.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages