title: express-session won't set cookie connect.sid
body: <p><strong>EDIT 5</strong></p>
  
  <p>I have back and front end running on LAMP environment accesible with <code>192.168.80.213/backend</code> adress.
  I try to make a push notification server using nodejs, socket.io and express framework to link back and front end.</p>
  
  <p>My nodejs server is listening on port <code>3000</code> while my backend and front end listenning on port 80 both using apache.</p>
  
  <p>Here is my node client : </p>
  
  <pre><code>&lt;script type="text/javascript" src="socket.io-1.4.5.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      var socket = io('http://192.168.80.213:3000/');
  &lt;/script&gt;
  </code></pre>
  
  <p>Here is my node server : </p>
  
  <pre><code>const   express          = require('express')
          , app            = express()
          , http           = require('http').Server(app)
          , socketIo       = require('socket.io')(http)
          , cookieParser   = require('cookie-parser')
          , cookie         = require('cookie')
          , connect        = require('connect')
          , expressSession = require('express-session')
          , port           = 3000
          , helmet         = require('helmet')
          , name           = 'connect.sid'
          , sessionStore   = new expressSession.MemoryStore({ reapInterval: 60000 * 10 })
          , sessionSecret  = 'VH6cJa7yZSmkRbmjZW#J3%CDn%dt'
          , environment    = process.env.NODE_ENV || 'development'
          ;
  
  /** Configuration **/
  app.enable('trust proxy');
  app.disable('x-powered-by');
  app.use(helmet());
  app.use(cookieParser());
  app.use(expressSession({
      'name'  : name,
      'secret': sessionSecret,
      'store' : sessionStore,
      'resave': true,
      'saveUninitialized': true
  }));
  
  app.get('/', function(req, res) {
      res.writeHead(200, {'Content-Type': 'text/plain'});
      res.end('Hello from node');
  });
  
  socketIo.use(function(socket, callback) {
      // Read cookies from handshake headers
      var cookies = cookie.parse(socket.handshake.headers.cookie);
      // We're now able to retrieve session ID
      var sessionID;
      if (cookies[name]) {
          console.log( "cookies['" + name + "'] = " + cookies[name] );
          sessionID = cookieParser.signedCookie( cookies[name], sessionSecret );
          console.log( "sessionID = " + sessionID );
      }else{
          console.log( "cookies['" + name + "'] = undefined" );
      }
  
      if (!sessionID) {
          console.log('ERROR NO SESSION CONNECTION REFUSED !!');
          callback('No session', false);
      } else {
          // Store session ID in handshake data, we'll use it later to associate
          // session with open sockets
          socket.handshake.sessionID = sessionID;
          callback(null, true);
      }
  
  });
  
  
  socketIo.on('connection', function (socket) { // New client
      console.log( 'new connection..' );
      console.log('user ' + socket.handshake.sessionID + ' authenticated and is now connected.');  
  
  });
  
  /** Start server */
  http.listen(port);
  console.log( "listening on :" + port );
  </code></pre>
  
  <p>Go to <code>192.168.80.213:3000</code> and see 'Hello from node' and cookie['connect.sid'] is set according to screenshot below</p>
  
  <p><a href="https://i.stack.imgur.com/EzKbw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EzKbw.jpg" alt="connect.sid cookie correctly set"></a></p>
  
  <p>And console output : </p>
  
  <p><a href="https://i.stack.imgur.com/HfFTi.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HfFTi.jpg" alt="enter image description here"></a></p>
  
  <p>Now Clearing cache and i'm going to my back end app where is my nodeClient <code>192.168.80.213/backend</code>.</p>
  
  <p>connect.sid cookie doesn't exist</p>
  
  <p><a href="https://i.stack.imgur.com/d1GcZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d1GcZ.jpg" alt="enter image description here"></a></p>
  
  <p>And console output : </p>
  
  <p><a href="https://i.stack.imgur.com/JbLC1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JbLC1.jpg" alt="enter image description here"></a></p>
  
  <p>Why express-session ain't set cookie.sid ? how can i fix that ? I'm new to node and express, i spend many times googling without succes, hope some node masters coul help me !!</p>
  
  <p>regards</p>