Wrapper of https://github.com/aralejs/cookie
meteor add chuangbo:cookies
Get cookie. options:
converterfunction. Cookie will be pass through converter and return the result, only if value is not undefined.- Options can be an object。
converterandraw. Cookie is decoded when writing/reading by default, unless specificrawto true.
// setup
document.cookie = 'foo=1';
document.cookie = 'bar=2';
Cookie.get('foo');
// returns '1'
// converter
Cookie.get('bar', function(s) { return parseInt(s); } );
// returns 2
Cookie.get('not_exists');
// returns undefinedSet cookie. options can contain path(string), domain(string), expires(int or Date object), raw(bool). When raw set to true, cookie will not be encoded.
Cookie.set('foo', 3);
Cookie.set('bar', 4, {
domain: 'example.com',
path: '/',
expires: 30
});Delete cookie.
Cookie.remove('foo');
Cookie.remove('bar', {
domain: 'example.com',
path: '/'
});