【发布时间】:2016-06-05 04:22:06
【问题描述】:
我阅读了Hapijs's guide on cookies 并尝试实现它。在我的主 index.js 文件中,我按照建议放置了配置:
server.state('data', {
ttl: null,
isSecure: true,
isHttpOnly: true,
encoding: 'base64json',
clearInvalid: false,
strictHeader: true
});
然后在我的路线中,我使用一些数据设置 cookie“数据”来测试它,如下所示:
{
method: 'POST',
path: '/create',
handler: function (request, reply) {
reply('hello').state('data', { firstVisit: true });
}
}
当我在 chrome 调试工具中检查 cookie 时,它没有显示 cookie。奇怪的是它确实回复了 hello 并且它也没有输出任何错误。有人知道我做错了什么吗?
谢谢!
【问题讨论】: