简体   繁体   English

universal_cookie__WEBPACK_IMPORTED_MODULE_3__.default.remove 不是函数

[英]universal_cookie__WEBPACK_IMPORTED_MODULE_3__.default.remove is not a function

whenever am i trying to remove cookie its show me this error.每当我尝试删除 cookie 时,它都会向我显示此错误。

TypeError: universal_cookie__WEBPACK_IMPORTED_MODULE_3__.default.remove is not a function

this is my code这是我的代码

 Logout = () =>{
    var user = Cookies.get('shailuKiCookie');
    // console.log(user);
    if(user){
      Cookies.remove("shailuKiCookie");
      // alert("logout successfully");
      window.location.reload(false);
    }else{
      window.location.reload(false);
    }
  }

enter image description here在此处输入图像描述

function set_cookie(name, value) {
  document.cookie = name +'='+ value +'; Path=/;';
}
function delete_cookie(name) {
  document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}

You don't have to specify a cookie value when you delete a cookie.删除 cookie 时不必指定 cookie 值。

Just set the expires parameter to a past date:只需将 expires 参数设置为过去的日期:

note: HttpOnly cookies cannot be deleted with JavaScript on the client side.注意:HttpOnly cookies 不能在客户端用 JavaScript 删除。

you should create a Cookies object.你应该创建一个 Cookies 对象。

const cookies = new Cookies()
cookies.remove('cookie name')

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

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