'session' is undefined when using express / redis for session store

后端 未结 5 1953
半阙折子戏
半阙折子戏 2020-11-30 06:06

I\'m trying to use redis for sessions in my express app.

I do the following:

var express = require(\'express\');
var RedisStore = require(\'connect-r         


        
5条回答
  •  臣服心动
    2020-11-30 06:18

    Things have changed recently with Express 3 / Express 4. Please confirm you are using version 4.

    The complete middleware concept changed. You need to install these middlewares manually. "express-session" is one of the 4.0 middlewares.

    I recommend to read

    http://scotch.io/bar-talk/expressjs-4-0-new-features-and-upgrading-from-3-0 and https://github.com/visionmedia/express/wiki/Migrating-from-3.x-to-4.x

    Additionally some users were confused that the github repo itself is named just "session" but

    npm install express-session
    

    is correct.

提交回复
热议问题