Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

292
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!