tongs

0.7.1 • Public • Published

tongs npm version Build Status

cookie utility. don't dependency jquery.

motivation

jquery-cookie is awsome!! but jquery ....

Build Status Matrix

Sauce Test Status

Install

browser

Download here

<script src="/path/to/tongs.js"></script>

npm

npm install tongs
var tongs = require('tongs');

Usage

Set cookie:

tongs().cookie('name', 'value');

Set cookie with option:

tongs().cookie('name', 'value', {expires: 7, path: '/'});

Get Cookie:

tongs().cookie('name'); // => value
tongs().cookie('nothing'); // => undefined

Get all available cookies:

// document.cookie => name1=value1, name2=value2
tongs().cookie();
// => [{name1: value1}, {name2: value2}]

Remove Cookie:

tongs().remove('name'); // => true
tongs().remove('nothing'); // => false
 
//with option
tongs().cookie('path_cookie', 'value', {path: '/'});
tongs().remove('path_cookie'); // => false
tongs().remove('path_cookie', {path: '/'}); // => true

Get wide domain

// location.hostname => dl.dropboxusercontent.com
tongs().wideDomain(); // => .dropboxusercontent.com

ex) use cookie across the subdomain

var set_domain = tongs().wideDomain();
tongs().cookie('name', 'valkue', {domain: set_domain});

Readme

Keywords

Package Sidebar

Install

npm i tongs

Weekly Downloads

3

Version

0.7.1

License

MIT

Last publish

Collaborators

  • niwaringo