-
Notifications
You must be signed in to change notification settings - Fork 16
Description
SID is too generic of a name for session id cookie. The regex conflicts with php's PHPSESID.
also, there is no way to manage the session variables from the core.js wrapper.
I think the best way to fix it is to rename SID to JSNODESID and to export a configuration object for opts. Also I think the history code in there is inappropriate.. same with the user="guest" stuff.. that's useful for a framework or cms.... so that should be ripped out i think.. then
renaming the sid:
in sessions.js:
if(req.headers.cookie) {
var m = req.headers.cookie.match(/NODEJSSID=([^ ,;]*)/);
if (m) {
m = m[1];
if (sessions[m])
return m;
}
}
...... then ..
Session.prototype.getSetCookieHeaderValue=function(){var parts
parts=['NODEJSSID='+this.id]
fixing the opts issue is simple
.. in core.js
exports.opts = exports.opts||{lifetime:604800};
exports.session = function( request, response, callback){
session = sessions.lookupOrCreate(request, exports.opts);
response.setHeader('Set-Cookie', session.getSetCookieHeaderValue());
request.session = session;
request.sessionRoot = sessions.sessionRoot;
callback(request, response);
};
..
then call it like this from the controller:
var http = require('http'),
session = require('sesh');
session.opts.path = "/path";
session.magicSession();
..
anyway, awesome work on the gorilla patch, much love