Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 53 lines (34 sloc) 1.098 kb
def1196 James Halliday initial thing
authored
1 cookie-cutter
c275342 James Halliday documentation and browserify as a dev dep
authored
2 =============
def1196 James Halliday initial thing
authored
3
c275342 James Halliday documentation and browserify as a dev dep
authored
4 Set and get cookies in the browser or in node with `document`.
5
6 In your browser code with [browserify](github.com/substack/node-browserify):
7
8 ````javascript
9 var cookie = require('cookie-cutter');
10 var times = parseInt(cookie.get('times'), 10) || 0;
11 cookie.set('times', times + 1);
12 ````
13
14 and `times` will increment every time the page is reloaded.
15
16 methods
17 =======
18
19 ````javascript
20 var cookie = require('cookie-cutter');
21 ````
22
23 cookie(document)
24 ----------------
25
26 Return a new cookie object with `.get()` and `.set()` operating on `document`.
27
28 `document.cookie` should be a non-referentially transparent setter/getter combo
29 like the DOM's variant where assignment with optional path and expiry creates a
30 new cookie in the getter as a key=value pair.
31
32 cookie.get(key)
33 ---------------
34
35 Return the cookie value for `key`.
36
37 cookie.set(key, value, opts={})
38 -------------------------------
39
40 Set the cookie at `key` to `value` with optional parameters `expiry` and `path`.
41
42 install
43 =======
44
45 With [npm](http://npmjs.org) do:
46
47 npm install cookie-cutter
48
49 license
50 =======
51
52 MIT/X11
Something went wrong with that request. Please try again.