How do I delete a cookie from a specific domain using Javascript?

前端 未结 3 908
天涯浪人
天涯浪人 2020-12-30 06:31

Let\'s say I am at http://www.example.com and I want to delete a cookie whose domain is .example.com and another one whose domain is www.example.com

3条回答
  •  有刺的猬
    2020-12-30 07:17

    We need to set the cookie for delete them.

    Example:

    this.cookieService.set(cookiename, '', new Date('Thu, 01 Jan 1970 00:00:01 GMT'));
    

    Please refer below Git location for more details. https://github.com/7leads/ngx-cookie-service/issues/5 https://github.com/angular/angular/issues/9954

提交回复
热议问题