0

我有以下代码片段,它删除了当前域的 cookie。

login(isRedirect) {
    this.spinner.show();
    this.auth.loginUser({ shopId: -1, tillNumber: -2 })
        .subscribe((response: any) => {
            if (response && response.responseCode && response.redirectUrl && response.responseCode === 302 && isRedirect) {
                window.location.href = response.redirectUrl;
            } else if (response && response.posSessionId) {
                this.router.navigate(['/']);
                this.toastr.success('Logged in!');
            } else {
                this.cookie.deleteAll('/', config.COOKIE_DOMAIN)
            }
            this.spinner.hide();
        }, err => {
            this.spinner.hide();
        });
}

它在本地主机上工作正常,但当我将代码推送到服务器并访问生产 url 上的站点时,它不起作用。

value of COOKIE_DOMAIN is ".testServer.com"
My localhost is on http://localhost.testServer.com:4200/
My production server is on https://origin-merchant.testServer.com

仅供参考:当我在 Firefox 上打开生产站点但在 chrome 上没有打开生产站点时,cookie 删除逻辑工作正常。

4

0 回答 0