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

262
Views
Set sessionStorage expiration

I have this code which sets a sessionStorage. It works fine but I would like to set an expiration date of 24 hours. Can I do this? I know this can be done with cookies but not sure with sessionStorage objets.

<script>
  
  var pageViewed = parseInt("1");
  
  if(sessionStorage.pageViewed)
  {
    var intSessionStoragePageViewed = parseInt(sessionStorage.pageViewed);
    pageViewed =  intSessionStoragePageViewed + 1;
    sessionStorage.setItem("pageViewed", pageViewed);
  }
  else if(!sessionStorage.pageViewed)
  {
    
    sessionStorage.setItem("pageViewed", pageViewed);
  }
  
  </script>
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

localStorage and sessionStorage do not have built-in expiration dates like cookies do. sessionStorage is erased at the end of the browser session; localStorage is erased only when you or the end user explicitly erases it.

If you want locally stored data to expire after a specific duration, use cookies.

about 4 years ago · Santiago Trujillo 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!