title: Node.js & Express session problem
body: <p>I'm having a problem with sessions, where sometimes the session variable I <em>just</em> set
  is undefined on the next page request.  I typically have to go through the flow
  again in order to properly set the variables.</p>
  
  <p>I can confirm that I'm not trying to set the session variables to undefined; they have a legit value.</p>
  
  <p>In my app, users move from /twitter/connect/ to /twitter/callback/.  The former retreives some oauth data from twitter, the latter logs the user into twitter.</p>
  
  <p>/twitter/connect/ is simple:</p>
  
  <pre><code>app.get('/twitter/connect/?', function(req, res){
      consumer().getOAuthRequestToken(function(error, oauthToken, oauthTokenSecret, results){
          if (error){
              // error handling here
          } else {
              req.session.oauthRequestToken = oauthToken;
              req.session.oauthRequestTokenSecret = oauthTokenSecret;
  
              // if I console.log the two session variables above
              // they have the proper values.
  
              res.redirect("https://twitter.com/oauth/authorize?oauth_token="+req.session.oauthRequestToken);      
          }
      });
  });
  </code></pre>
  
  <p>After that, twitter sends them back to /twitter/callback/:</p>
  
  <pre><code>app.get('/twitter/callback/?', function(req, res){
      console.log(req.session.oauthRequestToken);
      console.log(req.session.oauthRequestTokenSecret);
  
      // more often than not, the two variables above are
      // undefined.  but not always.  usually on the first
      // pass, never on the second.
  });
  </code></pre>
  
  <p>I have no idea what's going on, I can confirm that the session variables are being set properly, they just aren't holding their value in between page requests, but only the first time.</p>
  
  <p>This is how I'm creating my server:</p>
  
  <pre><code>app.configure('development', function(){
      app.use(express.cookieParser());
      app.use(express.session({ secret:'yodawgyo' }));
      app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
      app.use(express.logger());
      app.use(express.static(__dirname + '/public'));
      app.set('view engine', 'ejs');
      app.set('view options', {
          open: '{{',
          close: '}}'
      });
  });
  </code></pre>
  
  <p>I just have a dev environment for now.  I have Node 0.5.0-pre installed, but saw this issue on 0.4.1 as well.  I'm using express 2.3.2.</p>
  
  <p>Any help is much appreciated.</p>