慕哥6287543
使用express-mysql-session中间件可以解决const http = require('http'), express = require('express), app = express(), session = require('express-session'), Store = require('express-mysql-session'); let options = { host:"localhost", user:"root", password:"", port:"3306", database:"data"}session({ name:'sid', secret:'abc', resave:false, saveUninitiailzed:true, store:new Store(options), cookie:{ maxAge:1000*60*60*24 }})http.createServer(app).listen(80);随便加个session就可以在指定的数据库中看到名字叫sessions的表了