Skip to content

Commit

Permalink
Merge 2501747 into d62ef21
Browse files Browse the repository at this point in the history
  • Loading branch information
andreax79 committed Nov 21, 2014
2 parents d62ef21 + 2501747 commit 3b9496a
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ module.exports = function(opts){

// to pass to Session()
req.sessionOptions = opts;
req.sessionOptions = {};
for (var key in opts) {
req.sessionOptions[key] = opts[key];
}
req.sessionKey = name;

req.__defineGetter__('session', function(){
Expand Down Expand Up @@ -183,6 +187,38 @@ Session.prototype.__defineGetter__('populated', function(){
return !!this.length;
});

/**
* Return the cookie options
*
* @return {Object}
* @api public
*/

Session.prototype.__defineGetter__('opts', function(){
return this._ctx.sessionOptions;
});

/**
* Change the session cookie max age
*
* @param {Number} val
* @api public
*/
Session.prototype.__defineSetter__('maxAge', function(val){
this._ctx.sessionOptions.maxage = val;
this.save();
});

/**
* Return the session cookie max age
*
* @return {Number}
* @api public
*/
Session.prototype.__defineGetter__('maxAge', function(){
return this._ctx.sessionOptions.maxage;
});

/**
* Save session changes by performing a Set-Cookie.
*
Expand Down

0 comments on commit 3b9496a

Please sign in to comment.