diff --git a/lib/session.js b/lib/session.js index a49100e..d3ac38d 100644 --- a/lib/session.js +++ b/lib/session.js @@ -1,7 +1,7 @@ /* session.js - sessions module for node.js - Core Sesssion Logic : - inimino@inimino.org + Core Sesssion Logic : + inimino@inimino.org 2009-12-01 MIT License @@ -108,12 +108,21 @@ function cleanup(){var id,now,next timeout=setTimeout(cleanup,next - (+new Date) + 1000)} function idFromRequest(req,opts){var m - // look for an existing SID in the Cookie header for which we have a session + // look for an existing JSNODESID in the Cookie header for which we have a session if(req.headers.cookie - && (m = /SID=([^ ,;]*)/.exec(req.headers.cookie)) + && (m = /JSNODESID=([^ ,;]*)/.exec(req.headers.cookie)) && ownProp(sessions,m[1])){ return m[1]} + //otherwise we search the GET-params + var params = require('url').parse(req.url, true).query || {}; + if (params.JSNODESID) { + return params.JSNODESID; + } + + //FIXME: + // RESTful: /SESSION_ID/ + // otherwise we need to create one // if an ID is provided by the caller in the options, we use that if(opts.sessionID) return opts.sessionID @@ -149,7 +158,7 @@ function randomString(bits){var chars,rand,i,ret return ret} Session.prototype.getSetCookieHeaderValue=function(){var parts - parts=['SID='+this.id] + parts=['JSNODESID='+this.id] if(this.path) parts.push('path='+this.path) if(this.domain) parts.push('domain='+this.domain) if(this.persistent) parts.push('expires='+dateCookieString(this.expiration)) @@ -168,4 +177,4 @@ function pad(n){return n>9 ? ''+n : '0'+n} Session.prototype.destroy=function(){ delete sessions[this.id]} -Session.prototype.serialize // unimplemented, but would store the session on disk \ No newline at end of file +Session.prototype.serialize // unimplemented, but would store the session on disk