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

120
Vistas
Cookies getting refreshed because of my script
  ******Cookies.set("recently_viewed",'[1]' , 3, "/");*********
  var productIDArray =  JSON.parse(Cookies.get("recently_viewed"))
  if(productIDArray == null) productIDArray = [];
  productID =  window.location.href.split("product_view/")[1].split("/")[0]
  // alert(productID)
  if (productIDArray.length < 7){
    if (productIDArray.indexOf(productID) === -1) {
          productIDArray.unshift(productID);
          
      }
      
  }
  else{
    if (productIDArray.indexOf(productID) === -1) {
        productIDArray.pop(productID);
        productIDArray.unshift(productID);
        
      }
  }
  
  Cookies.set("recently_viewed", JSON.stringify(productIDArray), 3, "/");

So Im trying to execute this script which appends the product id from url to the cookie named recently_viewed. By default this cookie doesnt exist, so im being forced to use the first line which i enclosed in ***

But that keeps resetting the cookie value everytime i reload the page.

Is there any efficient way to do this?

Thanks in advance

about 4 years ago · Juan Pablo Isaza
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