Meteor Cookie
Wrapper of https://github.com/aralejs/cookie
Usage
get Cookie.get(name, [options])
Get cookie. options
:
converter
function. Cookie will be pass through converter and return the result, only if value is not undefined.- Options can be an object。
converter
andraw
. Cookie is decoded when writing/reading by default, unless specificraw
to true.
1// setup 2document.cookie = 'foo=1'; 3document.cookie = 'bar=2'; 4 5Cookie.get('foo'); 6// returns '1' 7 8// converter 9Cookie.get('bar', function(s) { return parseInt(s); } ); 10// returns 2 11 12Cookie.get('not_exists'); 13// returns undefined 14
set Cookie.set(name, value, [options])
Set 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.
1Cookie.set('foo', 3); 2 3Cookie.set('bar', 4, { 4 domain: 'example.com', 5 path: '/', 6 expires: 30 7});
remove Cookie.remove(name, [options])
Delete cookie.
1Cookie.remove('foo'); 2 3Cookie.remove('bar', { 4 domain: 'example.com', 5 path: '/' 6});