cookie-dough
An isomorphic JavaScript cookie library.
Wraps https://www.npmjs.com/package/cookie to work on the client and server. Also, required is having parsed cookies in express (for now).
Usage
Geting a cookie
// client-side// automatically parses the cookies for the pagevar cookie = ;cookie; // server-sidevar express = CookieDough = cookieParser = ; var app = ;app; app;
Getting all the cookies
// client-side// automatically parses the cookies for the pagevar cookie = ; // returns an object with all of the cookies// format: { cookieName: "cookie value" }cookieall; // server-sidevar express = CookieDough = cookieParser = ; var app = ;app; app;
Setting a cookie
// client-sidevar cookie = ;cookie; // server-sidevar express = CookieDough = cookieParser = ; var app = ;app; app;
The options that you can set on a cookie:
path - cookie path
expires - absolute expiration date for the cookie (Date object)
maxAge - relative max age of the cookie from when the client receives it (seconds)
domain - domain for the cookie
secure - true or false
httpOnly - true or false
Removing a cookie
// client-sidevar cookie = ;cookie; // server-sidevar express = CookieDough = cookieParser = ; var app = ;app; app;
The options that can be set to remove a cookie are:
path - cookie path
domain - domain for the cookie