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

289
Vistas
Persistent cookie being deleted as soon as Safari is closed and reopened (working fine in Chrome, Firefox)

I'm using the following JavaScript code to store a cookie with a ID in the browser of the website visitor for 60 days.

While it is working perfectly in Chrome, Firefox etc. in Safari the cookie disappears after closing and reopening the browser. (happens with iPhones, Macbooks etc., even in the standard cookie-configuration)

function setCookie() {
    const date = new Date;
    date.setDate(date.getDate() + 60);
    var uid = Date.now().toString(36) + Math.random().toString(36).substring(2);
    document.cookie = "ck=" + uid + "; expires=" + date + "; path=/";
}

Does anyone have an idea, why this could be happening? Greetings!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I decided to set and read the cookie with php, now it is working. Maybe that is the better option anyways, since cookies set with document.cookie can only last maximum 7 days in Safari, before they get automatically deleted (according to this overview)

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