1.0.0-beta.8 • Published 2 years ago

@sofiakb/cookie v1.0.0-beta.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Contributors Forks Stargazers Issues MIT License

comment: <> (LinkedIn)

About The Library

comment: <> (The library allows to detect os system in PHP project.)

Built With

This section should list any major frameworks that you built your project using. Leave any add-ons/plugins for the acknowledgements section. Here are a few examples.

Prerequisites

Installation

npm install --save @sofiakb/cookie

Usage

cookie.set(string key, var value, object options)

Set cookie with specified key and value with options. value can be a object. Available options are:

  • expires: Days of expiration.
  • days: Alias of expires.
  • path: Path of cookie.
  • domain: Domain of cookie.
  • secure: HTTPS only.
import cookie from 'json-cookie';

cookie.set('test', 'test');		// test=test
cookie.set('json-test', { name: '.modernator' });    // json-test={"name":".modernator"}

cookie.set('ex-test', 'test', {
	expires: 1
});		// ex-test=test; expires= ...

cookie.get(string key)

Get cookie with key. If cookie isn't exist, it returns undefined.

import cookie from 'json-cookie';

cookie.get('test');		// test
cookie.get('json-test');	// Object { name: '.modernator' }

cookie.delete(string key)

Delete cookie with key.

import cookie from 'json-cookie';

cookie.delete('test');
cookie.get('test');		//

Roadmap

See the open issues for a list of proposed features (and known issues).

License

Distributed under the MIT License. See LICENSE for more information.