From c51af4b391a8b8ef46d970761c98ab127610b9b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Yves=20G=C3=A9rardy?= Date: Sat, 18 Aug 2012 19:52:02 +0200 Subject: [PATCH] Fix the connect sessions. --- lib/user.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/user.js b/lib/user.js index 9af58bd..e1ea6fd 100644 --- a/lib/user.js +++ b/lib/user.js @@ -56,11 +56,17 @@ exports.initialize = function (nowjs) { }; // Populate session by parsing cookie - var cookie = this.user.cookie[nowjs.options['cookieKey']]; - if (cookie) { - this.user.session = nowjs.sessions[unescape(cookie)]; + var sid = decodeURIComponent(this.user.cookie['connect.sid']); + if (sid) { + var self = this; + nowjs.sessionStore.get(sid, function (err, session) { + self.user.session = session; + return; + }); } + + // set to true upon first replaceVar and emit connect event /** * @private