Title: Detect consent in JavaScript
Last modified: December 2, 2020

---

# Detect consent in JavaScript

 *  Resolved [Matt Lowe](https://wordpress.org/support/users/squelch/)
 * (@squelch)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/detect-consent-in-javascript/)
 * I’m writing a plugin which will set a whole bunch of arbitrary cookies. On the
   client side I want to be able to detect whether or not the user has consented
   to cookies or not before doing so. Is there a function provided by this plugin
   that I can call to find out whether consent has been given? I had a look at the
   CLI object exposed by the plugin, but couldn’t see anything in there to say whether
   cookie consent had been obtained.

Viewing 1 replies (of 1 total)

 *  Plugin Author [WebToffee](https://wordpress.org/support/users/webtoffee/)
 * (@webtoffee)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/detect-consent-in-javascript/#post-13757538)
 * Hi [@squelch](https://wordpress.org/support/users/squelch/),
 * You can use the function wt_cli_is_consent_given() to get the consent status.
   This function will return “true” if the user has given consent to cookies. Else
   it will return “false”.
 *     ```
       <script>
       	function wt_cli_is_consent_given() {
       		if (CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME) == 'yes' && CLI_Cookie.read("cookielawinfo-checkbox-non-necessary") == 'yes') {
       			return true;
       		}else {
       			return false;
       		}
       	}
       </script>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Detect consent in JavaScript’ is closed to new replies.

 * ![](https://ps.w.org/cookie-law-info/assets/icon.svg?rev=3007243)
 * [CookieYes – Cookie Banner for Cookie Consent (Easy to setup GDPR/CCPA Compliant Cookie Notice)](https://wordpress.org/plugins/cookie-law-info/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cookie-law-info/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cookie-law-info/)
 * [Active Topics](https://wordpress.org/support/plugin/cookie-law-info/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cookie-law-info/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cookie-law-info/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [WebToffee](https://wordpress.org/support/users/webtoffee/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/detect-consent-in-javascript/#post-13757538)
 * Status: resolved