Ok, so here is the scenario. I have the user log into my app with facebook. When this happens Passport saves it to the Session (req.user). This works all well and good when I am working in a page that has access to the request object, but I find myself in the situation where I don't have access to request, but I need to check the user object.
Case in point. I am using socket.io and when I am working with the sockets and the methods surrounding them, I don't have access to the request object and therefore I can't get user info.
I keep hearing that I need to stay away from globals whenever possible, but I can't see a way around it.
Thoughts?
Below is an example of me working with sockets. This module is called from my server.js file.
function loadSockets(io)
{
    var articleCommand = require('./middleware/ArticleCommand');
    io.sockets.on('connection', function (socket) {
        socket.on('getArticles', function(){
            if (NEED USER INFO HERE !== null){
                articleCommand.getArticlesByUser(NEED USER INFO HERE, function(error, articles){
                    io.sockets.emit('articlesRetrieved', error, articles);
                });
            }
        });
    });
}
exports.loadSockets = loadSockets;
Update
Ok, so based on the commenters advice I have installed this: https://github.com/aviddiviner/Socket.IO-sessions and applied it...but my session is always null in my sockets.
Here is what I have.
var socket = sio.enable({
    socket: io.listen(server, {'log level': 1, 'heartbeat': false}),   
    store:  mystore,                // this is my Redis store
    parser: express.cookieParser()
});
later on...when processing my sockets
socket.sockets.on('connection', function (socket, session) { ...
The session is always null...even though my passport has loaded up my session correctly.
Thoughts?