cookie code

Hello>(google translate)...

The European cookies policy had me worried, by my clients, because it forces to warn of the cooks that are installed ... (I do not know very well when and why I load them) ...


I found this code that works for me:

Example:

www.neoclick.es

Web Properties / Web Site / HTML Code (body):

<!--//BLOQUE COOKIES-->
<div id="barraaceptacion">
<div class="inner">
Solicitamos su permiso para obtener datos estad&iacute;sticos de su navegaci&oacute;n en esta web, en cumplimiento del Real Decreto-ley 13/2012. Si contin&uacute;a navegando consideramos que acepta el uso de cookies.
<a href="javascript:void(0);" class="ok" onClick="PonerCookie();"><b>OK</b></a> |
<a href="http://neoclick.es/politicas.htm" target="_self" class="info">M&aacute;s informaci&oacute;n</a>
</div>
</div>

<script>
function getCookie(c_name){
var c_value = document.cookie;
var c_start = c_value.indexOf(" " + c_name + "=");
if (c_start == -1){
c_start = c_value.indexOf(c_name + "=");
}
if (c_start == -1){
c_value = null;
}else{
c_start = c_value.indexOf("=", c_start) + 1;
var c_end = c_value.indexOf(";", c_start);
if (c_end == -1){
c_end = c_value.length;
}
c_value = unescape(c_value.substring(c_start,c_end));
}
return c_value;
}

function setCookie(c_name,value,exdays){
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

if(getCookie('tiendaaviso')!="1"){
document.getElementById("barraaceptacion").style.d isplay="block";
}
function PonerCookie(){
setCookie('tiendaaviso','1',365);
document.getElementById("barraaceptacion").style.d isplay="none";
}
</script>
<!--//FIN BLOQUE COOKIES-->

Head:



<link href="cookies.css" rel="stylesheet" type="text/css">




> We create a .css (I'll bet it works by sticking it in the Head)


body {
margin: 0;
padding: 0;
background-color: # 333;
}

#barraaceptacion {
display: none;
position: fixed;
left: 0px;
right: 0px;
bottom: 0px;
padding-bottom: 20px;
width: 100%;
text-align: center;
min-height: 40px;
background-color: rgba (0, 0, 0, 0.5);
color: #fff;
z-index: 99999;
}

.inner {
width: 100%;
position: absolute;
padding-left: 5px;
font-family: verdana;
font-size: 12px;
top: 30%;
}

.inner a.ok {padding: 4px; color: # 00ff2e; text-decoration: none;}
.inner a.info {padding-left: 5px; text-decoration: none; color: # faff00;}