Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

264
Vistas
How to make a html code only display once a day?

I want to show a preview player but i am going to add a refresh code that refreshes the page in 5 minutes so they can only see the html code for 5 minutes so my question is how would i set it up to make a cookie so it will only show my HTML code one time PER day. If they refresh it will say "YOU USED YOUR PREVIEW FOR TODAY COME BACK TOMORROW" or something..... Here is what i have tried Any help is greatly Appreciated i can use HTML or PHP it dont matter to me which :)

    <head>
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
    </head>
    <body>
    <div id="dialog" title="Test dialog">
    MY HTML CODE HERE
    </div>
    </body>
    </script>
    $(document).ready(function() {
    
       // Make sure dialog is initially hidden:
       $('#dialog').dialog({autoOpen: false});
    
        // Check for the "whenToShowDialog" cookie, if not found then show the dialog and save the cookie.
        // The cookie will expire and every 2 days and the dialog will show again.
    
        if ($.cookie('whenToShowDialog') == null) {
    
            // Create expiring cookie, 1 days from now:
            $.cookie('whenToShowDialog', 'yes', { expires: 1, path: '/' });
    
            // Show dialog
            $('#dialog').dialog("open");        
        }
    
    });
    </script>
PREVIEW USED FOR TODAY COME baCK TOMORROW
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can set a cookie that expires at the end of the day when a user visits the site.

document.cookie = `visited=true; expires=${dateObjectForEndOfDay}`;

Then, when a client visits the page you can read the cookie and see if it is set. Expired cookies won't display, so if the last cookie has expired it will be as if the user had never visited the site. (The below code is pinched from w3Schools

function getCookie(cname) {
  let name = cname + "=";
  let decodedCookie = decodeURIComponent(document.cookie);
  let ca = decodedCookie.split(';');
  for(let i = 0; i <ca.length; i++) {
    let c = ca[i];
    while (c.charAt(0) == ' ') {
      c = c.substring(1);
    }
    if (c.indexOf(name) == 0) {
      return c.substring(name.length, c.length);
    }
  }
  return "";
}

const siteWasVisited = getCookie('visited');
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda