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

282
Views
How to set persistent cookies that stay even after closing window?

I am trying to set cookies that have to be persistent even if the user closes the browser.

document.cookie = name=${generateString()}; 'expires=Sun, 1 Jan 2023 00:00:00 UTC; path=/';

But when I close the window, and I open it again there is no cookie saved.

My goal is to save somehow the current user without him/her being logged and create a temporary user.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You should consider using localStorage. For example:

// setting an item with name "expires"
localStorage.setItem('expires', 'Sun, 1 Jan 2023 00:00:00 UTC');

// retrieving the item
const expires = localStorage.getItem('expires');
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!