tongs
v0.7.1
Published
cookie utility. don't dependency jquery.
Downloads
3
Readme
tongs
cookie utility. don't dependency jquery.
motivation
jquery-cookie is awsome!! but jquery ....
Build Status Matrix
Install
browser
<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});