It looks like you're doing everything right, so I'm afraid I don't have a direct answer for you. However, I hope this will help you debug the problem.
The first thing I would do is look at the various failure conditions in the session middleware, and see if any of them might be an issue in your production environment. That code is located in your project directory here:
node_modules/express/node_modules/connect/middleware/session.js
Look for the line starting with function session(options){
; that's where the party starts. About 25 lines later, you'll see return function session(req, res, next){
; that's the actual middleware. If you browse through that source, you'll see various reasons why the session
variable might not be set (anything that throws an error or returns next()
). For example, the store can be disconnected, or there's a pathname mismatch. Sometimes, debug()
is called on failure, so you could try enabling debugging logging. Just set the environment variable DEBUG
to express:*
. I haven't used Nodejitsu yet, but I'm sure there's a way you can set environment variables and examine your logs.
If you can enable remote debugging on Nodejitsu, then even better: that way you could actually step through the session
middleware and find out where it's failing (or if it's not getting called for some reason). I looked through the public Nodejitsu documentation, and didn't see anything about remote debugging, but that doesn't mean it can't be done.