added some info to readme
This commit is contained in:
Родитель
56bd81877b
Коммит
2696233bda
41
README.md
41
README.md
|
@ -1 +1,40 @@
|
|||
secure sessions stored in cookies, for node.js
|
||||
secure sessions stored in cookies, for node.js
|
||||
|
||||
The session content is built to be secure and tamper-free.
|
||||
|
||||
API
|
||||
===
|
||||
|
||||
We don't want this library to depend on making any other calls, e.g. cookieParser.
|
||||
|
||||
var cookieSessions = require("cookie-sessions");
|
||||
app.use(cookieSessions({
|
||||
cookieName: 'session',
|
||||
secret: 'blargadeeblargblarg',
|
||||
cookie: {
|
||||
path: '/api',
|
||||
httpOnly: true, // defaults to true
|
||||
secure: true // defaults to true
|
||||
}
|
||||
}));
|
||||
|
||||
// later, in a request
|
||||
req.session.foo = 'bar';
|
||||
req.session.baz = 'baz2';
|
||||
|
||||
// results in a Set-Cookie header
|
||||
|
||||
// no updates to session results in no Set-Cookie header
|
||||
|
||||
// and then
|
||||
if (req.session.foo == 'bar') {
|
||||
// do something
|
||||
}
|
||||
|
||||
// have the session expire 24 hours from now
|
||||
// this will not refresh automatically with activity
|
||||
// you have to call req.session.setExpires again
|
||||
req.session.setExpires(24 * 60 * 60 * 1000);
|
||||
|
||||
// clear the session
|
||||
req.session.clear();
|
|
@ -9,7 +9,8 @@
|
|||
"url" : "https://github.com/benadida/cookie-session"
|
||||
},
|
||||
"dependencies" : {
|
||||
"vows": "0.5.13"
|
||||
"vows": "0.5.13",
|
||||
"cookies" : "https://github.com/jed/cookies/tarball/588822c"
|
||||
},
|
||||
"author" : {
|
||||
"name" : "Ben Adida",
|
||||
|
|
Загрузка…
Ссылка в новой задаче