Cookie删除问题

时间:2019-01-14 06:11:36

标签: javascript

当我尝试从一个客户端切换到一个客户端时出现此错误      其他我将其存储为以下代码的地方

 user = JSON.parse(getCookie('user'));
 clientObj = JSON.parse(getCookie('client'));.

我已使用以下代码删除cookie。

export function deleteCookie() {
var cookies = document.cookie.split("; ");
for (var c = 0; c < cookies.length; c++) {
    var d = window.location.hostname.split(".");
    while (d.length > 0) {
        var cookieBase = encodeURIComponent(cookies[c].split(";") 
   [0].split("=")[0]) + '=; expires=Thu, 01-Jan-1970 00:00:01 GMT; 
    domain=' + d.join('.') + ' ;path=';
        var p = location.pathname.split('/');
        document.cookie = cookieBase + '/';
        while (p.length > 0) {
            document.cookie = cookieBase + p.join('/');
            p.pop();
        };
        d.shift();
    }
}
}

下面是错误代码。

   VM30:1 Uncaught SyntaxError: Unexpected token u in JSON at 
   position 0
   at JSON.parse (<anonymous>)

0 个答案:

没有答案
相关问题