Jump to content

need help installing cookie bar script


BrainPill

Recommended Posts

 

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

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 by BrainPill
Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...