BrainPill Posted March 30, 2019 Share Posted March 30, 2019 Hi, I need help installing a cookie bar script. I run the script serverside !! Its found at this site: https://cookie-bar.eu/ I went to the cookiebar menu option. Under installation is written to grab the 'code below' but I can't find it. I think the code above is not useful. Can someone explain how to install the external js script correctly? As an example of how I tested this I included this code: <html> <head> </head> <body> <br><br><br> <a href="#" onclick="document.cookie='cookiebar=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/'; setupCookieBar(); return false;">Click here to revoke the Cookie consent</a> <br><br><br> Test script for cookies <br><br> <script src="cookiebar-latest.js"></script> </body> </html> Link to comment Share on other sites More sharing options...
BrainPill Posted April 2, 2019 Author Share Posted April 2, 2019 (edited) Maybe I'm making an error. But I am not that good with javacript. I'm used to PHP. If a php routine or variable is not executed then I used var_dump() to show the result on screen. How can I check if the js script I call is executed? I tried to use the console found in Chrome, here is an error report like this : Uncaught SyntaxError: Invalid or unexpected token What does that tell? Edited April 2, 2019 by BrainPill Link to comment Share on other sites More sharing options...
justsomeguy Posted April 2, 2019 Share Posted April 2, 2019 That means there is a syntax error in the code. Your browser's developer console includes an area where you can look at all of the Javascript source code and set breakpoints to see if it's being executed. If the code is minified and all on one line that doesn't really help with breakpoints though. Link to comment Share on other sites More sharing options...
BrainPill Posted April 3, 2019 Author Share Posted April 3, 2019 I solved it by placing other code found in the other menu part. basically its this: https://cookie-bar.eu/#configuration Link to comment Share on other sites More sharing options...
BrainPill Posted April 4, 2019 Author Share Posted April 4, 2019 Its still not working the way I want it to work. I run the script this way ( I repeat: I installed it localhost) After clicking the Allow Cookies button actually the page should refresh but that doesn't happen. This the script: <html> <?php if (isset($_COOKIE['cookiebar'])){ if ($_COOKIE['cookiebar'] == "CookieAllowed") { // The user has allowed cookies, let's load our external services echo '<br> cookie is set analytics code can be executed <br><br>'; }} ?> <head> <script type="text/javascript" src="cookiebar-latest.js?tracking=1&always=1&top=1&showNoConsent=1&showPolicyLink=1&remember=Autodetect&privacyPage=Default%20(black)"> </script></head><body></body> </html> meaning that the first visit is not counted. Now this should be done this way. It is not allowed anymore to place any kind of code to set a cookie if the user doesn't agree with it. Im terrible with javascript. Which code should I use exactly after the Allow Cookies button is clicked? Link to comment Share on other sites More sharing options...
justsomeguy Posted April 5, 2019 Share Posted April 5, 2019 Either have PHP check and only include the Javascript to set the cookies if they've allowed it, or have the Javascript check the cookie before it tries to set its own. Link to comment Share on other sites More sharing options...
BrainPill Posted April 7, 2019 Author Share Posted April 7, 2019 This is solved thanks for the help Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now