QUESTION:
Is there any way to create a variable storage in per session/http request? The variable must be globally accessible and different
You can an unstable feature: nodejs domains
I do this on top of my head so read the docs and figure out really how it works ;)
Create a middleware high up in the hierarchy that will create a domain and run the remaining request handlers in the context of that domain:
app.use(function(req, res, next) {
var domain = domain.create();
domain.req = req;
domain.run(next);
});
Then anywhere in your handlers, you can access the current request with:
var req = process.domain.req;
Again, read the docs, I'm really not sure about all this but this is one approach!