0

Ok basically I've got Express 4 running and I want to get the value of a cookie on every page, I felt that app.locals was a good fit for this but I cannot get it grab a cookies value in app.js

I tried

app.use(function(req,res,next){
    app.locals.uid = req.cookies['uid']
}

However it makes it so none of my pages ever load so anyone got some experience with this?

Coombes
  • 203
  • 1
  • 10

1 Answers1

0

use res.locals (http://expressjs.com/4x/api.html#res.locals) instead - app.locals are the same for all application, and res.locals are unique for each request

vodolaz095
  • 6,680
  • 4
  • 27
  • 42