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

127
Vistas
¿Cookie sigue siendo HttpOnly de manera predeterminada cuando no está configurado para hacerlo?

Estoy tratando de agregar temas simples a mi sitio web. Se supone que el script crea una cookie de tema para ver qué tema se usa y luego aplica el estilo. Solía funcionar, pero ahora se configura en httpOnly (lo que significa que JS no puede cambiarlo, incluso si JS lo crea). Se establece en http solo verdadero, incluso si trato de configurarlo específicamente en falso, lo que me impide cambiarlo. Aquí está el código:

 // Themes var numOfThemes = 2; var theme = 0; // Standart getCookie function copied from w3schools function getCookie(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for(var i = 0; i <ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } // This function sets the theme depending on the value inside the theme cookie (eg.: "theme=3") function applyTheme() { var cookie = parseInt(getCookie("theme")); var hs = document.getElementsByTagName('style'); if(hs.length > 1); for (var i=0, max=hs.length; i < max; i++) { hs[i].parentNode.removeChild(hs[i]); } switch(cookie) { case 0: theme = 0; break; case 1: theme = 1; var style = document.createElement('style'); style.innerHTML = ``; document.head.appendChild(style); break; //... } } // This is supposed to set the cookie inside the browser. I tried adding HttpOnly=false; at the end but it doesn't change anything function setTheme(theme) { const d = new Date(); d.setTime(d.getTime() + (365*24*60*60*1000)); var expires = "expires="+ d.toUTCString(); document.cookie = "theme=" + theme + ";" + expires + ";path=/;SameSite=Lax;"; } // this is the function for switching the theme on a button click function themeSwitch() { var theme = + parseInt(getCookie("theme")) + 1; if(theme > 4) { theme = 0; } setTheme(theme); } applyTheme();
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