1

I have a problem with the local storage feature of JS I have two html pages and when you finish the game you get redirected to a reward page and a password it's passed via local storage to the second page, this worked well when the pages were on local host, after I uploaded online the local storage is not working. Here is the code for the first page:

 localStorage.setItem('passw', "1234")
 alert(localStorage.getItem('passw'));
 location.replace("https://smartcup.online/BrandedGames/Voucher-10.html");

And here is the code for the second page (if no password is is local storage we get redirected to the first page)

alert(localStorage.getItem('passw'));
if(localStorage.getItem('passw') == null){
   location.replace("https://www.smartcup.online/BrandedGames/HangMan/HangManGame.html")
    }

The alert on the second page return null but I don't know why. I will leave the link of the page bellow to try it:https://www.smartcup.online/BrandedGames/HangMan/HangManGame.html. The word you have to guess is "bag" Thank you for the attention.

wazz
  • 4,953
  • 5
  • 20
  • 34
  • 3
    Does this answer your question? [Why do two web pages have different localStorage? How can I fix this?](https://stackoverflow.com/questions/18709523/why-do-two-web-pages-have-different-localstorage-how-can-i-fix-this) – James Jul 27 '21 at 17:26
  • 1
    James is right. your "www" subdomain is being viewed as separate local storage. – Dean Jul 27 '21 at 18:34

0 Answers0