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?

[Code]

var express = require('express')
 var session = require('express-session')
 var RedisStore = require('connect-redis')(session)
 var cookieParser = require('cookie-parser')
 var app = express()
 app.use(cookieParser())
 app.use(session({
 secret: 'test',
 store:  new RedisStore({
 host:   '127.0.0.1',
 port:   6379
 }),
 resave: true,
 saveUninitialized: true
 }))
 
 app.get('/', function (req, res) {
 console.log(req.session)
 Console.log(req.session plus' ......................')
 Console.log (req.session.isvisit plus' ......................')
 if(req.session.isVisit) {
 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')
 bracket
 })

[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.