title: NodeJS: session variables shared for all clients (express-session)
body: <p>I'm using express-session for handling session variables in a NodeJS Application. I use session variables for handling login-authorization, for saving logged user information and other things.</p>
  
  <p>The thing is that this session variables are being shared for all clients, it looks like they are working as NodeJS instance variables instead of session variables for every client. What I want to have is session variables working as they work in PHP.</p>
  
  <p>This application is retrieving all the data from web services in a Laravel Back-End application.</p>
  
  <p>This is my code:</p>
  
  <p><strong>Initializing session:</strong></p>
  
  <pre><code>var sessionHelper = require('./helpers/session-helper');    
  var session = require('express-session');
  app.use(session({
      secret: config.SESSION_SECRET,
      resave: false,
      saveUninitialized: true,
      cookie: {secure: true}
  }));
  sessionHelper.init(session);
  global.SESSION = sessionHelper;
  </code></pre>
  
  <p><strong>session-helper module:</strong></p>
  
  <pre><code>var _session = null;
  module.exports = {
      init: function (session) {
          _session = session;
      },
      has: function (name) {
          return ((_session[name]) ? true : false);
      },
      get: function (name) {
          return _session[name];
      },
      set: function (name, value) {
          _session[name] = value;
      },
      clear: function (name) {
          _session[name] = undefined;
      }
  };
  </code></pre>
  
  <p><strong>Using session variables:</strong></p>
  
  <pre><code>SESSION.set('hotels', response.hotels);
  SESSION.get('hotels');
  </code></pre>
  
  <p>Thanks, </p>