Skip to content

Autoaccept cookies on some Region #161

Answered by orestbida
JiriBandura asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @JiriBandura,

yes, you can use the .accept() method to achieve this! I'm assuming you have some way of knowing what the current user's country is, and that this value is saved inside a variable — which I will simply call country.

Logic: if cc_cookie is not set and country=='Sweden' => accept all

const cc = initCookieConsent();

cc.run({ /*...*/ });

const country = 'Sweden'; //value retrieved from server/api ?

// If is from Sweden and cookieconsent has never been accepted before => accept all by default
if (country  === 'Sweden' && !cc.validCookie('cc_cookie')) {
    cc.accept('all');
};

Note that if the current user is from Sweden and he/she does not make any explicit choice himself …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@JiriBandura
Comment options

@orestbida
Comment options

@orestbida
Comment options

Answer selected by orestbida
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants