Title: How does cookie function work?
Last modified: August 31, 2016

---

# How does cookie function work?

 *  [d00mer](https://wordpress.org/support/users/d00mer/)
 * (@d00mer)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/how-does-cookie-function-work/)
 * Hi
    I would like use the function for desable code like adsense. How do I use
   it?
 *     ```
       if ( function_exists('cn_cookies_accepted') && cn_cookies_accepted() ) {
           // my adsense code here ?
       }
       ```
   
 * [https://wordpress.org/plugins/cookie-notice/](https://wordpress.org/plugins/cookie-notice/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [d00mer](https://wordpress.org/support/users/d00mer/)
 * (@d00mer)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/how-does-cookie-function-work/#post-7250413)
 * i tried like here [http://korben.info/respecter-loi-cookies-site.html](http://korben.info/respecter-loi-cookies-site.html)
 *     ```
       <script>
       if ( function_exists('cn_cookies_accepted') && cn_cookies_accepted() ) {
         (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
         (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
         m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
         })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
   
         ga('create', 'UA-69175630-1', 'auto');
         ga('send', 'pageview');
       }
       </script>
       ```
   
 * but doesnt working.
    what is wrong ?
 *  [neiltomlow](https://wordpress.org/support/users/neiltomlow/)
 * (@neiltomlow)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/how-does-cookie-function-work/#post-7250546)
 * Same question for me, but the developer won’t answer. Unfortunately…
 *  Plugin Author [dFactory](https://wordpress.org/support/users/dfactory/)
 * (@dfactory)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/how-does-cookie-function-work/#post-7250547)
 * [@d00mer](https://wordpress.org/support/users/d00mer/) you have mixed javascript
   and php code.
 * cn_cookies_accepted() is a php function, while it resides in a script tag.
 * The correct syntax would be sth like (but it depends where the function is places
   etc.):
 *     ```
       <?php
       if ( function_exists('cn_cookies_accepted') && cn_cookies_accepted() ) { ?>
       <script>
         (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
         (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
         m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
         })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
   
         ga('create', 'UA-69175630-1', 'auto');
         ga('send', 'pageview');
       </script>
       <?php } ?>
       ```
   
 * [@neiltomlow](https://wordpress.org/support/users/neiltomlow/) this is itended
   for developers. If you have difficulties making use of it just use the code block
   in the plugin settings and paste your javascript code there.
 * Regards,
    Bartosz / dfactory team

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How does cookie function work?’ is closed to new replies.

 * ![](https://ps.w.org/cookie-notice/assets/icon-256x256.png?rev=3549327)
 * [Compliance by Hu-manity.co](https://wordpress.org/plugins/cookie-notice/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cookie-notice/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cookie-notice/)
 * [Active Topics](https://wordpress.org/support/plugin/cookie-notice/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cookie-notice/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cookie-notice/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [dFactory](https://wordpress.org/support/users/dfactory/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/how-does-cookie-function-work/#post-7250547)
 * Status: not resolved