title: Passport Local strategy session using express in Node.js
body: <p>I'm a newbie in Node.js and used passport-local strategy for login session. I already set up all things in my web app, but I'm having a big problem with session.</p>
  
  <p>I tried multiple users can login to my web app at the same time, but there is a problem. One of users(ex. username is Paul) log in first, and then another user(Chris) is log in after, then Paul's view of my web app is changed to Chris' view.</p>
  
  <p>I'm not sure you guys understand what I mean by that but here is one of my code in Node.js</p>
  
  <pre><code>app.get('/location', isLoggedIn, function(req, res){
    var user_temp = {user: ''};
    user_temp.user = global_username;
    res.render('location/index1', user_temp);
  });
  </code></pre>
  
  <p>And below code is Passport local-Strategy</p>
  
  <pre><code>var LocalStrategy = require('passport-local').Strategy;
  passport.use('local-login',
    new LocalStrategy({
        usernameField : 'email',
        passwordField : 'password',
        passReqToCallback : true
      },
      function(req, email, password, done) {
        User.findOne({ 'email' :  email }, function(err, user) {
          if (err) return done(err);
          if (!user){
              req.flash("email", req.body.email);
              return done(null, false, req.flash('loginError', 'No user found.'));
          }
          if (!user.authenticate(password)){
              req.flash("email", req.body.email);
              return done(null, false, req.flash('loginError', 'Password does not Match.'));
          }
          var email_address = req.body.email;
          username_tmp = email_address;
          var username = email_address.substring(0, email_address.lastIndexOf("@"));
          global_username = username;
          pass = req.body.password;
          return done(null, user);
        });
      }
    )
  );
  </code></pre>
  
  <p>I think the problem is because of global_username, so Paul can see Chris' view of location. However, I don't know how to get the user variable and put that into ejs for each users.</p>
  
  <p>Can anybody help me out here....?</p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>P.S. If what I asked is confused,
  I can edit my question again and explain more...</strong></p>