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

174
Views
javascript: localStorage.getItem() returns value on same page, returns null on next page

Sorry for this easy question:

I am doing:

  localStorage.setItem("eventID", product); // set item to a storage so that we can retrive next page 
  var tests = localStorage.getItem('eventID');

  console.log(tests)

I can see in the console that it retrieves the value I stored into it.

Now when I am on the next page:

var eventID = localStorage.getItem('eventID');
console.log(eventID)

It is returned as null.

How can that be?

This is how I move to the next page:

<p class="regText">Please sign in with your account. If you haven't used the app <a href="page_createAcc.html">click here.</a></p>

Edit this is the full code:

Page1:

getURLArguments();

function getURLArguments(){


  const queryString = window.location.search;
  const urlParams = new URLSearchParams(queryString);
  const product = urlParams.get('eventID')

  localStorage.setItem("eventID", product); // set item to a storage so that we can retrive next page 
 
}

( I can see it working with console, so the issue is not with the arguments)

Page 2:

getEventID();

function getEventID(){
  var eventID = localStorage.getItem('eventID');
  console.log(eventID)

}

The page change comes from html (see above).

I tried running this within single folder and on server. Neither works.

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

0

I found out that above code is working fine on Safari but not on Firefox. It works on firefox, only when the pages are hosted live. On a local machine, it just didnt work. But the code is correct.

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!