Upload the .htaccess file from the Source directory to the document root of the website. If you already have a .htaccess file in use, then just copy and paste the content of the Korx.CookieComplier .htaccess file to the end of it.
Upload the korx.cookiecomplier.js file from the Source directory to your web server. On all your HTML pages you'll need to add the following as the first <script> in the <head> tag:
<script src="korx.cookiecomplier.js"></script>
Note: Change the src attributes to the correct location of where you've uploaded the korx.cookiecomplier.js file to e.g. "/scripts/korx.cookiecomplier.js"
You'll also need to add the following immeditately before the </head> tag.
<script defer="defer">Korx.CookieComplier.init();</script>
Note: Don't change the above script tags' defer and async attributes or positioning within the <head> tag otherwise there will be issues in some browsers.
You might also want to style the prompt by putting something like this in your CSS file:
#korx-cookiecomplier-prompt { position: absolute; bottom: 0; width: 100%; background: #000000; opacity: 0.8; font-size: 1.2em; color: #ffffff; } #korx-cookiecomplier-container { padding: 1.2em; overflow: hidden; } #korx-cookiecomplier-question { display: block; float: left; width: 100%; } #korx-cookiecomplier-allow { display: block; clear: left; float: left; color: #ffffff; } #korx-cookiecomplier-close { display: block; float: right; color: #555555; cursor: pointer; }
You can also specify your own consent question by passing it in as a string to the init function:
<script defer="defer">Korx.CookieComplier.init('We would like to set some cookies');</script>
If you want to change the link texts you can do this by passing in an object to the init function:
<script defer="defer">Korx.CookieComplier.init({ question:'Can we use cookies?', allow:'Yes', close:'' });</script>
In theory it'll work with any languages executed via the web server, but the Demo is written in PHP.
The client side geolocation feature uses GeoIP from MaxMind http://www.maxmind.com/app/javascript
If you want to take advantage of the server side geolocation feature, you'll need to have mod_geoip from MaxMind loaded in Apache. http://www.maxmind.com/app/mod_geoip
Now all you have to do is create a way for users to allow cookies. This is done by setting the cookie '_allow_cookies' to the value '1'. You can do this via JavaScript, PHP, or any other server side language.
An environment variable and cookie '_allow_cookies' will be set if cookies are allowed. You can use this to check if you need to ask the user to allow cookies.
Upload the korx.cookiecomplier.php file from the Source directory to your web server.
Add the following code to the top of each page where you want to accept or detect cookies:
<?php require_once('korx.cookiecomplier.php'); Korx_CookieComplier::init(); ?>
Note: Change the location to where you've uploaded the korx.cookiecomplier.php file to e.g. "/includes/korx.cookiecomplier.php"
Add the following code the the page where you want the user to have the option to allow cookies:
<?php if (!Korx_CookieComplier::allowed()) { echo '<a href="?_allow_cookies">Allow Cookies</a></p>'; } ?>
A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.
Found a bug in this plugin? Please report it this repository's Github Issues.
blog comments powered by Disqus