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

后端 未结 5 1954
半阙折子戏
半阙折子戏 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:30

    Sessions won't work unless you have these 3 in this order:

    app.use(express.cookieParser());
    app.use(express.session());
    app.use(app.router);
    

    I'm not sure if router is mandatory to use sessions, but it breaks them if it's placed before them.

提交回复
热议问题