php – Error call function Cookie Alert in a website-ThrowExceptions

Exception or error:

Hello friends I show you this code that I have I want to accept cookies to a web page.
What happens is that when I clicked the accept button it does nothing and the accept button linked to the accept cookies function is fine, right?
What I want is that when you click on accept, accept cookies, I would be very grateful if you could help me out

<!DOCTYPE html>
<head>
	<meta charset="utf-8">
	<title>C&oacute;digo de ejemplo | Pol&iacute;tica de Cookies</title>
	<meta name="description" content="">
    <link rel="stylesheet" type="text/css" href="assets/css/cookies-nou.css">
        <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
    <script>
    /* ésto comprueba la localStorage si ya tiene la variable guardada */
    function compruebaAceptaCookies() {
      if(localStorage.aceptaCookies == 'true'){
        cajacookies.style.display = 'none';
      }
    }

    /* aquí guardamos la variable de que se ha
    aceptado el uso de cookies así no mostraremos
    el mensaje de nuevo */
    function aceptarCookies() {
      localStorage.aceptaCookies = 'true';
      cajacookies.style.display = 'none';
    }

    /* ésto se ejecuta cuando la web está cargada */
    $(document).ready(function () {
      compruebaAceptaCookies();
    });
    </script>  
</head>
<body>
  
<!--//BLOQUE COOKIES-->
<p>Hola</p>
        <div id="reveal-cookies" class="reveal small reveal-cookies" data-reveal="gzpq3d-reveal" data-close-on-click="false" data-close-on-esc="false" role="dialog" aria-hidden="false" data-yeti-box="reveal-cookies" data-resize="reveal-cookies" tabindex="-1" data-events="resize" style="display: block; top: 127px;">
            <header class="reveal-cookies-header">
                <span class="reveal-cookies-title">Privacitat i cookies</span>
            </header>
            <section class="reveal-cookies-content">
                <div class="text">
                    Aquest lloc web fa servir cookies que ens faciliten dades personals com ara dades associades a la teva navegació en el nostre lloc web. Si fas click a ACCEPTO tant nosaltres com els nostres partners podrem instal·lar cookies o accedir a informació no sensible del teu dispositiu amb l'objectiu de personalitzar continguts i publicitat, proporcionar funcionalitats a les xarxes socials i analitzar el nostre tràfic i audiències, Si continues navegant considerem que acceptes el seu ús.
                </div>
                <div class="reveal-cookies-buttons">
                    <button type="button" class="btn btn-gray btn-big" data-config="/politica-de-cookies/#cookie-config"><a href="http://politicadecookies.com">Mes Informació</a></button>
                    <button type="button" onclick="aceptarCookies()" class="btn btn-primary-alt btn-big" data-save="">Aceptar</button>            
                </div>
            </section>
        </div>

<!--//FIN BLOQUE COOKIES-->
</body>
</html>	
How to solve:

You can run javascript cookie store function document.cookie = "username=John Doe"; after “clicked Accept cookies”

function acceptCookies(){
document.cookie = "username=John Doe";
}

For more info

Leave a Reply

Your email address will not be published. Required fields are marked *