我正在 Postman 中测试我的 API,但无法模拟注销.
I am testing my API in Postman and am having trouble simulating a log out.
如果我调用删除会话 cookie,会话 cookie 之后仍然存在,我仍然能够访问需要身份验证的路由.
If I do a call to delete the session cookie, the session cookie is still there afterwards, and I'm still able to access routes that require authentication.
服务器上的路由处理器是:
The route handler on the server is:
server.route({
method: 'DELETE',
path: '/sessions/_current',
handler: function(req, reply){
req.auth.session.clear();
reply({}).code(204);
}
});
这是带有 Hapi 的 Node.js,但没关系.
有没有办法删除 Postman 中的所有 cookie 或手动删除某些 cookie?
在 chrome 浏览器中手动删除它会从 Postman 中删除 cookie.
Manually deleting it in the chrome browser removes the cookie from Postman.
在您的 chrome 浏览器中转到 chrome://settings/cookies
In your chrome browser go to chrome://settings/cookies
找到cookie并将其删除
Find the cookie and delete it
根据下面的 Max890 评论(在我的 Google Chrome 版本(版本 63)中),现在是chrome://settings/content/cookies
然后转到查看所有 cookie 和站点数据"
As per Max890 comment below (in my version of Google Chrome (ver 63)) this is now
chrome://settings/content/cookies
Then go to "See all cookies and site data"
Google Chrome 79.0.3945.88 更新
chrome://settings/siteData?search=cookies
chrome://settings/siteData?search=cookies