title: session does not save after fetch post request with express
body: <p>Im making a post request with fetch and saving a token to session in an express api backend. However, the token wont be saved in the session even though i set <code>credentials</code> to <code>include</code> in fetch. Can anybody identify the problem for me? Thanks.</p>
  
  <p>sending token to api server:</p>
  
  <pre><code> fetch('http://localhost:3000/api/users', {
      method: 'post',
      headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json'
      },
      credentials: 'include',
      body: JSON.stringify({
        accessToken: user.accessToken,
  
      })
    })
    .then(res =&gt; res.json())
    .then(json =&gt; {
      console.log(json);
    })
    .catch(error =&gt; {
      console.log(error);
    });
  </code></pre>
  
  <p>server side:</p>
  
  <pre><code>app.use(morgan('dev'))
  app.use(cors({credentials: true}));
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(cookieParser());
  app.use(session({secret: 'ssshhhhh', resave: true, saveUninitialized: true}));
  
  
  app.post('/api/users', function(req, res) {
    if (!req.session.accessToken) {
  
      req.session.accessToken = req.body.accessToken;
    }
    ...
    ...
  })
  
  app.get('/api/users/token', function(req, res) {
    console.log(req.session);
    if (req.session.accessToken) {
      return res.json({ accessToken: req.session.accessToken });
    }
    return res.json({ accessToken: null });
  })
  </code></pre>
  
  <p>retrieving token from session:</p>
  
  <pre><code>fetch('http://localhost:3000/api/users/token', {
    credentials: 'include' 
  })
  .then(checkStatus)
  .then(response =&gt; {
    return response.json();
  })
  .then(json =&gt; {
    console.log(json);
  })
  .catch(err =&gt; {
    console.error(err);
  });
  </code></pre>
  
  <p><strong>Edit:</strong>
  this is headers from request:</p>
  
  <pre><code>{ host: 'localhost:3000',
    accept: '*/*',
    'if-none-match': 'W/"4d-oW2yTGBOs6aaA4LAPgNxNQ"',
    cookie: 'connect.sid=s%3AHXDL6Az0hRZeSGsJgjhw4kvVONBLz-yn.sOOAqbxaLQ6Z%2FfCdfGOmXf9XsYl3JdHvP%2FmfkUln1xA',
    'user-agent': 'cairn/1 CFNetwork/758.2.8 Darwin/15.3.0',
    'accept-language': 'en-us',
    'accept-encoding': 'gzip, deflate',
    connection: 'keep-alive' }
  Session {
    cookie:
     { path: '/',
       _expires: null,
       originalMaxAge: null,
       httpOnly: false } }
  GET /api/users/token 304 23.780 ms - -
  { host: 'localhost:3000',
    'content-type': 'application/json',
    cookie: 'connect.sid=s%3A1jat379BSZQCKvJV1pKL4_Cub9ApMFVI.m%2BQHkIewMl9Uzjg315GTC5aD5qpWESiQVNDnXrFFSbQ',
    connection: 'keep-alive',
    'if-none-match': 'W/"270-toaMUba3dhoaPENGp5EGaA"',
    accept: 'application/json',
    'accept-language': 'en-us',
    'content-length': '484',
    'accept-encoding': 'gzip, deflate',
    'user-agent': 'cairn/1 CFNetwork/758.2.8 Darwin/15.3.0' }
  </code></pre>