I have implemented session mechanism in my app on GAE node.js standard environment using express-session without store
value. Though it works without problems on localhost, session seems to be terminated regardless of how cookie.maxAge
is configured on GAE node.js standard environment. This is what I have:
app.use(session({
cookie: {
maxAge: 31536000000, // 1 year
secure: true
},
secret: SECRET,
resave: true,
saveUninitialized: true
}));
I assume this is caused by GAE not persisting memory and if so, I should add store
option. I looked for an easiest option and found memcache, but it's not yet available on GAE node.js standard.
store
option?store
on GAE node.js standard?You are correct that memory is not persistent in the App Engine standard environment: requests arriving to the same instance will be able to re-use memory, however, your app might run on many instances and these are anyway ephemeral.
GCP does not yet offer a memcache solution from Node.js on App Engine. The current recommendation is to use a third party solution like Redis Labs Memcache (see tutorial)
Once you have configured a memcache instance, you should be able to use a MemecachedStore
for your express session. See this sample
Another alternative could be to use Cloud Datastore to store sessions. See the nodejs-datastore-session node module. I have not tried it myself.