繁体   English   中英

我已经删除了“ Cookies”的令牌和csrftoken,为什么还有它们?

[英]I have removed the `Cookies`'s token and csrftoken, why still have them?

我有一个

这是我的关键代码:

        var that = this

        // clear sessionid, csrftoken
        that.$Cookies.remove('sessionid');
        that.$Cookies.remove('csrftoken');

        // login
        that.$http.post(Urls.users.login(), params).then((response) => {

          setTimeout(loading, 0)

          that.$Cookies.set('token', response.data.key);

          that.get_user_info()

        }).catch((response) => {
            debugger
            setTimeout(loading, 0)

          }
        )

main.js我这样配置,因此组件可以使用this.$Cookies

import Cookies from 'js-cookie';
Object.defineProperty(Vue.prototype, "$Cookies", { value: Cookies })

您会看到我已经删除了tokencsrftoken ,但是当我访问登录api时,请求中仍然包含tokencsrftoken

在此处输入图片说明

我是否在this.$Cookies清除了令牌和csrftoken,它本质上并没有清除成功。

我对这个问题很感兴趣。 为什么删除了一些cookie,但是当我发送请求时,该cookie仍在标题中?

所以我发现您使用js-cookie ,然后转到github并获得以下信息:

删除对当前页面路径有效的cookie:

Cookies.set('name', 'value', { path: '' });
Cookies.remove('name'); // fail!
Cookies.remove('name', { path: '' }); // removed!

重要! 删除Cookie时,除非您依赖默认属性,否则您必须传递用于设置Cookie的完全相同的路径和域属性。

希望可以帮到您〜

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM