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.
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.