Eri*_*rik 9 cookies subdomain node.js express
我需要在主域和所有子域之间共享会话cookie.我有两个基于expressjs框架的nodejs服务:
// example.local
...
app.use(session({
cookie: {
domain: "example.local"
}
, key: 'sid'
, secret: '[my secret]'
, saveUninitialized: true
, resave: true
, store: new RedisStore({
host: 'localhost',
port: 6379
})
}));
// blog.example.local
...
app.use(session({
// what should I write here? <---------
}));
Run Code Online (Sandbox Code Playgroud)
所以我的问题是我应该在会话配置中写什么blog.example.local才能访问现有的cookie example.local?
编辑:正如@yeiniel建议的那样,我应该使用相同的配置,blog.example.local如下所示:
// blog.example.local
...
app.use(session({
cookie: {
domain: "example.local"
}
, key: 'sid'
, secret: '[my secret]'
, saveUninitialized: true
, resave: true
, store: new RedisStore({
host: 'localhost',
port: 6379
})
}));
Run Code Online (Sandbox Code Playgroud)
是否足够或我可以优化它?
| 归档时间: |
|
| 查看次数: |
141 次 |
| 最近记录: |