title: Passport.js failing to serialize user
body: <p>I am using passport.js for Google, Facebook and Twitter logins only.</p>
  
  <p>Node.js v0.8.19 with express.js 3.1.0, and passportjs version 0.1.16.
  (passport-facebook - 0.1.5, twitter - 0.1.4 passport-goolge-oauth - 0.1.5 )</p>
  
  <p>Everything works fine for a while, after an hour or so of the app running passport.js stops serializing the user into the req.user session.</p>
  
  <p>Facebook and google are receiving meaning full data from their respective api's</p>
  
  <pre><code>passport.use(new FacebookStrategy({
      clientID: FACEBOOK_APP_ID,
      clientSecret: FACEBOOK_APP_SECRET,
      callbackURL: "http://localhost:3000/auth/facebook/callback"
    },
    function(accessToken, refreshToken, profile, done) {
        var temp = {} 
        temp.name = profile.displayName
        temp.id = profile.id
        console.log(temp)
        return done(null, temp);
  }));
  </code></pre>
  
  <p>The console.log here will successfully print user id and name, however after calling </p>
  
  <pre><code>passport.serializeUser(function(user, done) {
    done(null, user);
  });
  
  passport.deserializeUser(function(obj, done) {
    done(null, obj);
  });
  </code></pre>
  
  <p>Serialize and deserialize are taken from the passport-facebook <a href="https://github.com/jaredhanson/passport-facebook/blob/master/examples/login/app.js" rel="nofollow noreferrer">example.</a></p>
  
  <p>The user will not be attached to req.user.</p>
  
  <p>Twitter never gets that far, after returning to the callback url, twitter gives the error:</p>
  
  <pre><code>Error: failed to find request token in session
  [03/11 23:28:24 GMT]     at Strategy.OAuthStrategy.authenticate            
  </code></pre>
  
  <p><strong>Note:</strong> these failures only happen after a period of time, the work properly for a while. Thats why I think it may be a memory issue, like Im saving the session in memory instead of a cooke.</p>
  
  <p>This is my express app configuration</p>
  
  <pre><code>app.configure(function(){
    app.set('port', process.env.PORT || 8080);
    app.set('views', __dirname + '/views');
    app.set('view engine', 'jade');
    app.use(express.favicon());
    app.use(express.logger('dev'));
    app.use(express.cookieParser());
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(express.cookieSession({ secret: 'tobo!', cookie: { maxAge: new Date(Date.now() +     3600000), }}));
    app.use(passport.initialize());
    app.use(passport.session());
    app.use(app.router);
    app.use(express.static(__dirname + '/public'));
  });
  </code></pre>
  
  <p>I have looked at the mailing list etc, but I could not find something matching this problem.
  I have checked on my localhost and on a nodejitsu server. Everything works for a while then fails.</p>