gpt4 book ai didi

javascript - Node JS session 错误 : express-session deprecated

转载 作者:数据小太阳 更新时间:2023-10-29 04:00:34 29 4
gpt4 key购买 nike

我的 Node js 文件中有以下内容

var express = require('express');
var util = require('./lib/utility');
var partials = require('express-partials');
var bodyParser = require('body-parser');

var session = require('express-session');

/* abstracted some code */

app.use(session({
genid: function(req) {
return genuuid(); // use UUIDs for session IDs
},
secret: 'keyboard cat'
}));

当我启动服务器时,我得到

express-session deprecated undefined resave option; provide resave option server.js
express-session deprecated undefined saveUninitialized option; provide saveUninitialized option server.js

我很难弄清楚什么是弃用的?我从 https://github.com/expressjs/session 复制了示例

当我尝试加载页面时,我得到:

ReferenceError: genuuid is not defined at app.use.session.genid

最佳答案

来自 express 4.0 , express-session with odd warning message

正如警告所说,默认值会发生变化,因此他们希望通过现在明确设置值来确保当默认值确实发生变化时(在不久的将来),您不会遇到意外行为。

app.use(session({
secret: cookie_secret,
resave: true,
saveUninitialized: true
}));

关于javascript - Node JS session 错误 : express-session deprecated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28839532/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com