Skip to content

Commit

Permalink
Merge 3549dce into 2497dc5
Browse files Browse the repository at this point in the history
  • Loading branch information
galvez committed Aug 28, 2018
2 parents 2497dc5 + 3549dce commit edae6b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Readme.md
Expand Up @@ -53,6 +53,7 @@ const CONFIG = {
/** 'session' will result in a cookie that expires when session/browser is closed */
/** Warning: If a session cookie is stolen, this cookie will never expire */
maxAge: 86400000,
autoCommit: true, /** (boolean) automatically commit headers (default true) */
overwrite: true, /** (boolean) can overwrite or not (default true) */
httpOnly: true, /** (boolean) httpOnly or not (default true) */
signed: true, /** (boolean) signed or not (default true) */
Expand Down
8 changes: 7 additions & 1 deletion index.js
Expand Up @@ -42,7 +42,9 @@ module.exports = function(opts, app) {
} catch (err) {
throw err;
} finally {
await sess.commit();
if (opts.autoCommit) {
await sess.commit();
}
}
};
};
Expand All @@ -67,6 +69,7 @@ function formatOpts(opts) {
if (opts.overwrite == null) opts.overwrite = true;
if (opts.httpOnly == null) opts.httpOnly = true;
if (opts.signed == null) opts.signed = true;
if (opts.autoCommit == null) opts.autoCommit = true;

debug('session options %j', opts);

Expand Down Expand Up @@ -120,6 +123,9 @@ function extendContext(context, opts) {
},
},
session: {
commit() {
this[CONTEXT_SESSION].commit();
},
get() {
return this[CONTEXT_SESSION].get();
},
Expand Down

0 comments on commit edae6b4

Please sign in to comment.