When using Redis to store a session, the session is always undefined

  node.js, question

When doing user login and registration, it is necessary to use Redis for session storage, but when writing test code, the session has always been undefined. Why is this? In addition, in each visit, back to appearERR wrong number of arguments for 'set' commandI have not found the reason for my mistake, so I come here to consult.

After installing Redis, do you need to set up anything or use other middleware?


var express = require('express')
 var session = require('express-session')
 var RedisStore = require('connect-redis')(session)
 var cookieParser = require('cookie-parser')
 var app = express()
 secret: 'test',
 store:  new RedisStore({
 host:   '',
 port:   6379
 resave: true,
 saveUninitialized: true
 app.get('/', function (req, res) {
 Console.log(req.session plus' ......................')
 Console.log (req.session.isvisit plus' ......................')
 if(req.session.isVisit) {
 Res.send('<p > add req.session.isVisit add' time to this page < /p >')
 } else {
 req.session.isVisit = 1
 Res.send ('Welcome to Here for the First Time')

[screenshot of console]
At runtime, it always displays “welcome to come here for the first time” and cannot read the session.


Answer it yourself.
The problem was solved because the version of redis installed was changed from v2.6 to v2.8.