Ask coding questions

← Back to all posts
express session
dfnk (75)

how can I save data in my express session?

app.get('/', (req, res) => {
  req.session.save /* then some variable */ = 10;
  res.send('saved');
});
Comments
hotnewtop
techde (141)
app.use(session({
      token : your_token_value,
      key     : 'test',
      proxy   : 'true',
      store   : new MemcachedStore({
        hosts: ['127.0.0.1:11211'], //this should be where your Memcached server is running
        secret: 'memcached-secret-key' // Optionally use transparent encryption for memcache session data 
    })
}));

Credits to:https://stackoverflow.com/questions/47200350/save-data-in-express-session