http://senchalabs.github.com/connect/middleware-session.html mentions….
“Every session store must implement the following methods: “
- .get(sid,callback)
- .set(sid, session, callback)
- .destroy(sid, callback)
I’m using the following code to attempt to get the SID:
Node JavaScript, using Socket.io connection
io.sockets.on('connection', function(socket) {
var sid = socket.id;
if (sid) {
sessionStore.get(sid, function (error, session) {
console.log("Connect Sid: " + sid);
});
}
});
And i’m getting the following error:
TypeError: Object function RedisStore(options) {
options = options || {};
Store.call(this, options);
this.client = new redis.createClient(options.port || options.socket, options.host, options);
if (options.pass) {
this.client.auth(options.pass, function(err){
if (err) throw err;
});
}
if (options.db) {
var self = this;
self.client.select(options.db);
self.client.on("connect", function() {
self.client.send_anyways = true;
self.client.select(options.db);
self.client.send_anyways = false;
});
}
} has no method 'get'
Inclusion of redis
//Redis store for storage
var sessionStore = require('connect-redis')(express);
...
...
app.use(express.session({secret: "keyboard cat",store: new sessionStore}));
Taken from: https://github.com/visionmedia/connect-redis
This seems to work: