Node.js server restart drops the sessions

后端 未结 5 1756
Happy的楠姐
Happy的楠姐 2020-12-24 03:40

I\'m having fully functional user signup/authentication system using express and connect middleware.

app.use(express.session({store: require(\'connect\').ses         


        
5条回答
  •  天命终不由人
    2020-12-24 04:07

    also, if you're using express, you need to provide a secret when telling the app to use the redis middleware.

    so, follow Alfred's recipe above, but do the following...

    var express = require( 'express' );
    var RedisStore = require('connect-redis');
    
    app.use( express.cookieParser() );
    app.use( express.session( { secret: "keyboard cat", store: new RedisStore }));
    

提交回复
热议问题