my-simple-cookie
v1.4.0
Published
Simple cookie implementation
Downloads
6
Readme
My Simple Cookie
Simple cookie handling module
Setting a cookie:
cookies.set(cookieName, cookieValue[, opts]);
var cookies = require('my-simple-cookie');
cookies.set('newCookie', 'cookieValue', { expires: 60*60*24, path: '/' } );
Will create a new cookie named newCookie with the value newCookie with 1 day expiration and / as path cookie value should only be a string
Updating a cookie:
cookies.update(cookieName, cookieValue[, opts]);
cookies.set('newCookie', 'cookieValue', { expires: 60*60*24, path: '/' } );
// Or
cookies.update('newCookie', 'cookieValue', { expires: 60*60*24, path: '/' } );
Retrieving a cookie:
cookies.get(cookieName);
cookies.get('newCookie' );
Will return the value of "newCookie"
Removing a cookie
cookies.remove(cookieName);
cookies.remove('newCookie' );
Will delete the cookie "newCookie"
Options:
expires : (Number) Number of second till cookie expires in seconds {default to : closing browser}. path : (String) Path of the cookie {default to : / }. domain : (String) domain of the cookie {default to : current domain }. httponly : (Boolean) should we flag the cookie as httpOnly ? {default to : false }. secure : (Boolean) should we flag the cookie as secured ? {default to : false }.