Este sitio web utiliza cookies para realizar análisis y mediciones de tus visitas. [ Acepto ] [ Más información aquí ].

How to Create a Legal Advice for Cookies

LEGAL ADVICE ON COOKIES WITH IMPLICIT ACCEPTATION

To create a legal advice on cookies with implicit acceptation:

1. Add this PHP code before your HTML code:

session_start();

if ($_SESSION['cookie'] != 1) {

$advice = "<div style='text-align:center;bottom:0;position:fixed;width:100%;

z-index:1000;background-color:#D0D0D0;'>

If you continue navigating, you accept the use of cookies.

</div>";

$_SESSION['cookie'] = 1;

}

2. Add this code under <body>:

<?=$advice;?>

This code will generate a banner with a legal advice on cookies, which will be displayed only in the user's first visit. If the user keeps navigating, he will implicitly approve the use of cookies and the banner will disappear.

LEGAL ADVICE ON COOKIES WITH EXPLICIT ACCEPTATION

To create a legal advice on cookies with explicit acceptation:

1. Add this PHP code before the HTML code:

session_start();

if ($_COOKIE['cookie'] != 1) {

$advice = "<div id='advice' style='text-align:center;bottom:0;position:fixed;width:100%;

z-index:1000;background-color:#D0D0D0;'>

This website uses cookies. <a href='#' onclick='hide()'>[ Accept ]</a>

</div>";

}

2. Add this Javascript code inside the HTML header, between <head> and </head>::

<script language="javascript">

function hide() {

document.getElementById("advice").style.visibility = "hidden";

document.getElementById("advice").innerHTML = "";

document.cookie="cookie=1";

}

</script>

3. Add this code right under <body>:

<?=$advice;?>

This code will generate a banner with a legal advice on cookies that will only disappear when the user clicks on the acceptation button.

Añadir comentario