/
package.json
38 lines (38 loc) · 4.72 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
"name": "express-session",
"version": "1.0.2",
"author": {
"name": "TJ Holowaychuk",
"email": "tj@vision-media.ca",
"url": "http://tjholowaychuk.com"
},
"main": "./index.js",
"dependencies": {
"utils-merge": "1.0.0",
"cookie": "0.1.0",
"cookie-signature": "1.0.3",
"uid2": "0.0.3",
"buffer-crc32": "0.2.1",
"debug": "0.7.4"
},
"devDependencies": {
"mocha": "~1.17.0",
"connect": "2.13.0",
"supertest": "0.9.0",
"should": "3.1.2",
"cookie-parser": "1.0.0"
},
"scripts": {
"test": "mocha --bail --ui bdd --reporter list -- test/*.js"
},
"license": "MIT",
"readme": "# express-session\n\nSetup session store with the given `options`.\n\nSession data is _not_ saved in the cookie itself, however\ncookies are used, so we must use the [cookieParser()](cookieParser.html)\nmiddleware _before_ `session()`.\n\n## Example\n\n```js\n app.use(connect.cookieParser())\n app.use(connect.session({ secret: 'keyboard cat', key: 'sid', cookie: { secure: true }}))\n```\n\n**Options**\n\n - `key` cookie name defaulting to `connect.sid`\n - `store` session store instance\n - `secret` session cookie is signed with this secret to prevent tampering\n - `cookie` session cookie settings, defaulting to `{ path: '/', httpOnly: true, maxAge: null }`\n - `proxy` trust the reverse proxy when setting secure cookies (via \"x-forwarded-proto\")\n\n**Cookie options**\n\nBy default `cookie.maxAge` is `null`, meaning no \"expires\" parameter is set\nso the cookie becomes a browser-session cookie. When the user closes the\nbrowser the cookie (and session) will be removed.\n\n## req.session\n\nTo store or access session data, simply use the request property `req.session`,\nwhich is (generally) serialized as JSON by the store, so nested objects\nare typically fine. For example below is a user-specific view counter:\n\n```js\napp.use(cookieParser())\napp.use(session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }}))\n\napp.use(function(req, res, next){\n var sess = req.session;\n if (sess.views) {\n res.setHeader('Content-Type', 'text/html');\n res.write('<p>views: ' + sess.views + '</p>');\n res.write('<p>expires in: ' + (sess.cookie.maxAge / 1000) + 's</p>');\n res.end();\n sess.views++;\n } else {\n sess.views = 1;\n res.end('welcome to the session demo. refresh!');\n }\n})\n```\n\n## Session#regenerate()\n\nTo regenerate the session simply invoke the method, once complete\na new SID and `Session` instance will be initialized at `req.session`.\n\n```js\nreq.session.regenerate(function(err){\n // will have a new session here\n});\n```\n\n## Session#destroy()\n\nDestroys the session, removing `req.session`, will be re-generated next request.\n\n```js\nreq.session.destroy(function(err){\n // cannot access session here\n});\n```\n\n## Session#reload()\n\nReloads the session data.\n\n```js\nreq.session.reload(function(err){\n // session updated\n});\n```\n\n## Session#save()\n\nSave the session.\n\n```js\nreq.session.save(function(err){\n // session saved\n});\n```\n\n## Session#touch()\n\nUpdates the `.maxAge` property. Typically this is\nnot necessary to call, as the session middleware does this for you.\n\n## Session#cookie\n\nEach session has a unique cookie object accompany it. This allows\nyou to alter the session cookie per visitor. For example we can\nset `req.session.cookie.expires` to `false` to enable the cookie\nto remain for only the duration of the user-agent.\n\n## Session#maxAge\n\nAlternatively `req.session.cookie.maxAge` will return the time\nremaining in milliseconds, which we may also re-assign a new value\nto adjust the `.expires` property appropriately. The following\nare essentially equivalent\n\n```js\nvar hour = 3600000;\nreq.session.cookie.expires = new Date(Date.now() + hour);\nreq.session.cookie.maxAge = hour;\n```\n\nFor example when `maxAge` is set to `60000` (one minute), and 30 seconds\nhas elapsed it will return `30000` until the current request has completed,\nat which time `req.session.touch()` is called to reset `req.session.maxAge`\nto its original value.\n\n```js\nreq.session.cookie.maxAge;\n// => 30000\n```\n\n## Session Store Implementation\n\nEvery session store _must_ implement the following methods\n\n - `.get(sid, callback)`\n - `.set(sid, session, callback)`\n - `.destroy(sid, callback)`\n\nRecommended methods include, but are not limited to:\n\n - `.length(callback)`\n - `.clear(callback)`\n",
"readmeFilename": "README.md",
"description": "Setup session store with the given `options`.",
"_id": "express-session@1.0.2",
"dist": {
"shasum": "004478c742561774411ceb79733155a56b6d49eb"
},
"_from": "express-session@1.0.2",
"_resolved": "https://registry.npmjs.org/express-session/-/express-session-1.0.2.tgz"
}