title: session not persisting when using secure cookie in NodeJS with express-session
body: <p>I'm using NodeJS + express + express-session to persist a userID from anywhere in the application.</p>
  
  <p>On the first route, my session is defined</p>
  
  <pre><code>userProfileRoutes.route('/authentication').post((req, res) =&gt; {
    req.session.userID = 10; //example
    console.log(req.session)
  }
  </code></pre>
  
  <p>The result of the <code>console.log</code> is: </p>
  
  <pre><code>Session {
    cookie:
     { path: '/',
       _expires: null,
       originalMaxAge: null,
       httpOnly: true,
       secure: true },
    userID: 10 } // this is the right value
  </code></pre>
  
  <p>But then, from a different route, I can't see the value:</p>
  
  <pre><code>userProfileRoutes.route('/edit').get(function (req, res) {
    console.log('After the nav edit route');
    console.log(req.session);
  }
  </code></pre>
  
  <p>And this prints </p>
  
  <pre><code>Session {
    cookie:
     { path: '/',
       _expires: null,
       originalMaxAge: null,
       httpOnly: true,
       secure: true }
  } // ID VARIABLE DISAPEARS HERE
  </code></pre>
  
  <p>I am configuring <code>express-session</code> using these parameters: </p>
  
  <pre><code>app.use(session({
    secret: 'secret',
    proxy: true,
    resave: false,
    saveUninitialized: true,
    withCredentials: true,
    cookie: { secure: true },
    store: new MongoStore({ mongooseConnection: db })
  }));
  </code></pre>
  
  <p>Why is my userID not persisted between requests and on all routes?</p>