I'm working on a web app with Vanilla JS, CSS and HTML. In my app, I have an input field where you should write your name. When you submit the value, it should be stored and shown on the front page/settings. After refreshing the page the value disappears. Why?
window.save_data = function () {
  if (typeof (Storage) !== "undefined") {
    let input = document.getElementById('inputName').value;
    localStorage.setItem('name', input);
    document.getElementById('inputName').value = localStorage.getItem('name');
    let storedValue = localStorage.getItem("name");
    document.querySelector("#user-name").innerHTML = storedValue;
    console.log(storedValue);
    return storedValue;
  } else {
    alert("Sorry! No Web Storage support..")
  }
}<input type='text' name="name" id="inputName" />
      <button onclick="save_data()" type="button">Save</button> 
     
     
     
    