Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ a new SID and `Session` instance will be initialized at `req.session`
and the `callback` will be invoked.

```js
req.session.regenerate(function(err) {
req.session.regenerate(function(err, session) {
// will have a new session here
})
```
Expand All @@ -363,7 +363,7 @@ Reloads the session data from the store and re-populates the
`req.session` object. Once complete, the `callback` will be invoked.

```js
req.session.reload(function(err) {
req.session.reload(function(err, session) {
// session updated
})
```
Expand Down
13 changes: 7 additions & 6 deletions session/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ defineMethod(Session.prototype, 'save', function save(fn) {

/**
* Re-loads the session data _without_ altering
* the maxAge properties. Invokes the callback `fn(err)`,
* the maxAge properties. Invokes the callback `fn(err, session)`,
* after which time if no exception has occurred the
* `req.session` property will be a new `Session` object,
* although representing the same session.
* `req.session` property and `session` callback param will be
* the new `Session` object, although representing the same session.
*
* @param {Function} fn
* @return {Session} for chaining
Expand All @@ -93,7 +93,7 @@ defineMethod(Session.prototype, 'reload', function reload(fn) {
if (err) return fn(err);
if (!sess) return fn(new Error('failed to load session'));
store.createSession(req, sess);
fn();
fn(null, req.session);
});
return this;
});
Expand All @@ -113,7 +113,8 @@ defineMethod(Session.prototype, 'destroy', function destroy(fn) {
});

/**
* Regenerate this request's session.
* Regenerate this request's session. Invokes the callback `fn(err, session)`
* with the new session object or an error if one occurred.
*
* @param {Function} fn
* @return {Session} for chaining
Expand All @@ -140,4 +141,4 @@ function defineMethod(obj, name, fn) {
value: fn,
writable: true
});
};
}
2 changes: 1 addition & 1 deletion session/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Store.prototype.regenerate = function(req, fn){
var self = this;
this.destroy(req.sessionID, function(err){
self.generate(req);
fn(err);
fn(err, req.session);
});
};

Expand Down