Srl*_*rle 11 javascript cookies node.js express express-session
基本上我正在从a.example.com重定向到www.example.com,我希望能够在www.example.com上删除cookie(因为cookie是以.example.com作为cookie域创建的),但是以下代码不起作用.
我知道这个问题似乎是重复的问题,我尝试了类似问题的一切,但它不起作用.看看我已经尝试过的代码.
使用express 3.0.3和node 0.10.32.
快速会话中间件
...
var cookiedata = {
domain : '.example.com',
originalMaxAge : null,
httpOnly : false
};
app.use(express.session({
store : ...,
secret : ...,
key : 'express.sid',
cookie : cookiedata
}));
...
Run Code Online (Sandbox Code Playgroud)
注销功能
function logout(req, res){
...
req.session.destroy(function(){
req.session = null;
res.clearCookie('express.sid', { path: '/' });
res.redirect('https://www.example.com');
});
}
Run Code Online (Sandbox Code Playgroud)
我从类似问题中尝试过的
所以我把path : '/'快递会话中间件放在如下:
app.use(express.session({ ..., path : '/' });
Run Code Online (Sandbox Code Playgroud)
没有成功.
没有成功.
这是Express.JS的response.clearCookie(第749行的文件response.js).
var opts = merge({ expires: new Date(1), path: '/' }, options);
return this.cookie(name, '', opts);
Run Code Online (Sandbox Code Playgroud)
如果在此行设置断点,您将看到在无效日期报告过期.因此,不要使用response.clearCookie,只需使它像这一样立即过期.
response.cookie("express.sid", "", { expires: new Date() });
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17735 次 |
| 最近记录: |