我已经导入了cookie-parser模块了:
let express = require('express');
let session = require('express-session');
let bodyParser = require("body-parser");
let cookieParser = require('cookie-parser');
let RedisStore = require('connect-redis')(session);
let app = express();
let http = require('http').Server(app);
let io = require('socket.io')(http);
let mysql = require('mysql');
// 设置 Cookie
app.use(cookieParser('ldjfdhslf'));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static('public'));
// 设置session
app.use(session({
secret: 'ldjfdhslf',
name: 'chat.id',
store: new RedisStore({
host: "127.0.0.1",
port: 6379,
db: "chat_session"
}),
cookie: {maxAge: 24 * 60 * 60 * 1000},
resave: false,
saveUninitialized: true
}));
业精于勤,荒于嬉;行成于思,毁于随。