tinesoft/ngx-cookieconsent

Once user click on GOT IT button popup should Hide

chiraggmodi opened this issue · 5 comments

CookieConsent and Library Versions?

- cookieconsent version: 3.1.1
- ngx-cookieconsent version: 2.2.3

OS Version?

win : 10

Angular CLI: 8.1.1
Node: 12.2.0
OS: win32 x64
Angular: 8.1.1

Desired functionality

I want to hide cookie popup permanently when user click on got it button. I mean popup wont show to that user ever again. I like storing some value in cookie and then show popup based on that value. Some thing like that.

I am not sure how to achieve this.

Have you added your domain to the NgcCookieConsentConfig object?

{
    "cookie": {
        "domain": "your domain here"
    },
    ...
}

Also, remember to inject the NgcCookieConsentService in your AppComponent.

Had same annoying issue.

Added below code in main component

   this.statusChangeSubscription = this.ccService.statusChange$.subscribe(
      (event: NgcStatusChangeEvent) => {
        if (event.status === 'allow') {
          this.cookieService.set(IS_COOKIE_ALLOWED, 'true');
          this.ccService.destroy();
        } else {
          this.cookieService.delete(IS_COOKIE_ALLOWED);
        }
      });
    let isCookieAllowed = this.cookieService.get(IS_COOKIE_ALLOWED);
    if (isCookieAllowed == 'true') {
      this.ccService.destroy();
    }

Note:
there is cookieService imported (ngx-cookie-service in our project)
there is const IS_COOKIE_ALLOWED: string defined whenever you want (defined and exported in cookie.conf.ts in our project)

I have two domains rajeshyadav.net and rajeshkumaryadav.com in the domain I set .com site which works fine but when I open .net site I click got it and refresh page again it shows, can we pass two domains ?

@rajeshyadavdotnet I think this answers your question #36 (comment) it's not a detailed answer, but should get you started.

Thanks @fromm1990: your comments do indeed answer @chiraggmodi and @rajeshyadavdotnet's questions (which are unrelated by the way)

Closing for now