Permalink
Browse files

Fixed bug in session management

  • Loading branch information...
1 parent 7c7a4d7 commit ec7cb76be3f54cfb9e047e8e7c064eceac4c6a2e Finn Herpich committed with Dec 26, 2010
Showing with 8 additions and 5 deletions.
  1. +8 −5 grasshopper/lib/renderer.js
@@ -322,23 +322,24 @@ RequestContext.prototype._beginSession = function(callback) {
var self = this;
session.getSessionStore().beginSession(sessionId, function(err) {
if(!err) {
- this.sessionId = sessionId;
+ self.sessionId = sessionId;
self.addCookie(new gh.Cookie('GHSESSION', sessionId));
}
callback(err);
});
};
RequestContext.prototype.setSessionValue = function(key, value, callback) {
+ var self = this;
var store = session.getSessionStore();
var setter = function (err) {
if(err) {
callback(err);
} else {
- store.setValue(this.sessionId, key, value, callback);
+ store.setValue(self.sessionId, key, value, callback);
}
};
- var self = this;
+
store.hasSession(this.sessionId, function(err, has) {
if(err) {
callback(err);
@@ -369,21 +370,23 @@ RequestContext.prototype.unsetSessionValue = function(key, callback) {
};
RequestContext.prototype.getSessionValue = function(key, callback) {
+ var self = this;
var store = session.getSessionStore();
store.hasSession(this.sessionId, function(err, has) {
if(!err && has) {
- store.getValue(this.sessionId, key, callback);
+ store.getValue(self.sessionId, key, callback);
} else {
callback(err);
}
});
};
RequestContext.prototype.endSession = function(callback) {
+ var self = this;
var store = session.getSessionStore();
store.hasSession(this.sessionId, function(err, has) {
if(!err && has) {
- store.endSession(this.sessionId, callback);
+ store.endSession(self.sessionId, callback);
} else {
callback(err)
}

0 comments on commit ec7cb76

Please sign in to comment.