I have been struggling for a couple of days and I have made some good progress, but I can't get my session stuff to work quite right.
I have successfully used Passport to authenticate with Facebook. When I click on my login with FB button, the session is loaded perfectly and I have my req.user object all ready to go, but it seems to me that I should only have to do that once.
I know passport saves a cookie. I have looked it up and seen that working.
I am trying to detect if the user is already logged in on the load of my index page, but when I load the page the req.user object is always null and my passport.deserializeUser method never gets called to load it (if I click the log into FB button it does get called).
So my question is, how do you tell passport on page load to check the cookie and load up the user session if there is one?
Update - Ok, so for those finding this question at a later date, I just wanted to go over what I learned here (thanks to those of you who commented). Hopefully it will help someone else down the line.
I am used to .NET cookies which live regardless of a server. Node.js and passport don't work on the same premise. By default node.js uses a memorystore to keep its session. When you shut down node in terminal/command line (which you have to do each time you change your server code), the memorystore cookie information is reset and therefore any cookies tied to it are meaningless.
To fix this, I installed Redis (http://cook.coredump.me/post/18886668039/brew-install-redis) and hooked it up as my store (http://www.hacksparrow.com/use-redisstore-instead-of-memorystore-express-js-in-production.html).
This will work on Azure which is my planned production server so all is well.
Ok, here is some code. I am not sure what parts to put up...
This is server.js
/**
* Module dependencies.
*/
var express = require('express')
, app = express()
, partials = require('express-partials')
, http = require('http')
, server = http.createServer(app)
, io = require('socket.io').listen(server)
, routes = require('./routes')
// facebook
, passport = require('passport')
, facebookStrategy = require('passport-facebook').Strategy
// custom stuff
, urlCommand = require('./middleware/UrlCommand')
, azureCommand = require('./middleware/AzureCommand')
, userCommand = require('./middleware/UserCommand');
// Ports
var port = process.env.port;
if (isNaN(port))
  port = 3000;
server.listen(port);
//allows the use of Layouts
app.use(partials());
passport.serializeUser(function(user, done) {
  done(null, user.RowKey);
});
passport.deserializeUser(function (id, done) {
    console.log("deserialize");
    userCommand.findByID(id, function (err, user) {
        done(err, user);
    });
});
// Configuration
app.configure(function () {
    app.set('views', __dirname + '/views');
    app.set('view engine', 'jade');
    app.use(express.cookieParser());
    app.use(express.bodyParser());
    app.use(express.session({ secret: 'SECRET!' }));
    app.use(express.methodOverride());
    app.use(passport.initialize());
    app.use(passport.session());  
    app.use(app.router);
    app.use(express.static(__dirname + '/public'));
});
app.configure('development', function(){
  app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.configure('production', function(){
  app.use(express.errorHandler());
});
// Facebook
passport.use(new facebookStrategy({
    clientID: CLIENT,
    clientSecret: "SECRET",
    callbackURL: "http://localhost:3000/auth/facebook/callback" //DEV
},
  function (accessToken, refreshToken, profile, done) {
      userCommand.findOrCreate(profile.id, profile.name.givenName,   profile.name.familyName, profile.emails[0].value, accessToken, function (error, user) {
          return done(null, user);
      });
  }
));
// Routes
app.get('/', routes.index);
app.get('/auth/facebook', passport.authenticate('facebook', { scope: 'email' }));
app.get('/auth/facebook/callback', passport.authenticate('facebook', { successRedirect:   '/',
                                                                   failureRedirect: '/login' }));
// Sockets
io.sockets.on('connection', function (socket) {
    // when the client emits 'sendURL', this listens and executes
    socket.on('sendURL', function (data) {
        console.log('sendURL called: ' + data);
        urlCommand.AddURL(data);
        // we tell the client to execute 'processURL'
        io.sockets.emit('urlComplete', data);
    });
});
console.log("Express server listening on port %d in %s mode", port, app.settings.env);
index.js
exports.index = function (req, res) {
    console.log(req.user); // ALWAYS NULL
    res.render('index', { title: 'Express' })
};
UserCommand
var azureCommand = require('../middleware/AzureCommand');
var tableService = azureCommand.CreateTableService();
function findByID(id, callback) {
    console.log('FindByID');
    tableService.queryEntity('user', 'user', id, function (error, entity) {
        console.log('Found him: ' + entity.Email);
        callback(error, entity);
    });
}
function findOrCreate(id, first, last, email, accessToken, callback) {
    var user = {
        PartitionKey: 'user'
        , RowKey: id
        , First: first
        , Last: last
        , Email: email
        , AccessToken: accessToken
   }
    tableService.insertEntity('user', user, function (error) {
        callback(null, user);
    });
}
exports.findByID = findByID;
exports.findOrCreate = findOrCreate;
This is what my output log shows when I output my session...
node server.js
info  - socket.io started
Express server listening on port 3000 in development mode
{ cookie:
   { path: '/',
     _expires: null,
     originalMaxAge: null,
     httpOnly: true },
  passport: {} 
}
debug - served static content /socket.io.js
				
				The problem is in your serializeUser and deserializeUser functions. 
As you noticed, when you click the FBlogin button deserializeUser is called for the first and only time - actually it's called with a id that has been before returned just before by serializeUser function. If at this moment it will not be able to find the user by the id provided, passport.user will not be saved into the session. 
As a consequence, in following requests passport.deserializeUser isn't called at all because express.session doesn't fills req.session with the passport's user id.
To sum up: you need to check if your serializeUser returns an id than can be understood and  deserialized by your deserializeUser.
FYI: a correct req.user object for a authenticated user should look like this:
{ 
   cookie: { path: '/', _expires: null,  originalMaxAge: null, httpOnly: true },
   passport: { user: 51772291b3367f0000000001 } 
}
				
			Well, at first you should post some code because the problem could be anywhere.
Than check the beautiful documentation http://passportjs.org/guide/
Despite passport brings a lot of examples via github to you.
If you want to have an complete example with different authentication methods you should visit https://github.com/madhums/nodejs-express-mongoose-demo