Unable to get session from session store

I have read and copy pasted a lot of examples on using sessions with socket.io, express and a session store. However, every time I call sessionStore.get() (or sessionStore.load()) all I get back is undefined. Why?

Here's my code (simplified):

var app = require('express')(),
    session = require('session'),    
    MongoStore = require('connect-mongostore')(session);

app.use(session({
    store: new MongoStore({ 'db': 'sessions' });
}));

io.use(function(socket, next) {
    var req = socket.request,
        reqCookie = cookie.parse(req.headers.cookie),
        sessid = reqCookie['connect.sid']; // == actual session ID

    sessionStore.get(sessid, function(err, session) {
        err // == undefined
        session // == undefined
    });
    next() ;
});

I also tried with session.MemoryStore in stead of connect-mongostore, with the same result. I modified node_modules/express-session/session/memory.js to try and log out the sessions in the sessionStore:

MemoryStore.prototype.get = function(sid, fn){
  var self = this;    
  console.log(self.sessions); // Output: {}

I'm a newbie when it comes to sessions and such, so thank you for bearing with me.

Update: I have tried the code on two different systems and networks, but I still get the same result.

So I finally figured out how to solve this. It turns out that the session id returned from socket ios socket.request.headers.cookie is not entirely identical to the session id returned from nodejs' req.sessionID.

Here's how I get the session id in both cases, and an example of what they return.

Normal http request

app.get('/', function(req, res) {
    req.sessionID; // == LMKJxTssmDgf8IxwijbC9G6LtDBuTQWX

});

Socket.io

io.use(function(socket, next) {

    var req = socket.request;

    if (req.headers.cookie) {
        req.cookie = cookie.parse(req.headers.cookie);

        req.cookie['express.sid']; // == s:LMKJxTssmDgf8IxwijbC9G6LtDBuTQWX.ApVkBxAEf4o3Pdgo0PWDRHi+GvBaSdcK7q1pO4xslZ0

As you can see, the session id is there in both cases, we just have to delete some stuff on the one socket.io gives us. Solution: req.cookie['express.sid'].split('.')[0].split(':')[1];.