title: sessionStorage returns undefined in one field, but works in other
body: <p>I have this code:</p>
  
  <pre><code>// Run on page load
  window.onload = function() {
  
      // If values are not blank, restore them to the fields
      var personal_number = sessionStorage.getItem('personal_number');
      if (personal_number !== undefined){
          $('#personal_number').val(personal_number);
      }
  
      var email = sessionStorage.getItem('email');
      if (email !== undefined){
          $('#username').val(email);
      }
  
      var password= sessionStorage.getItem('password');
      if (password !== undefined){
          $('#password').val(password);
      }
  }
  
  // Before refreshing the page, save the form data to sessionStorage
  window.onbeforeunload = function() {
      sessionStorage.setItem("personal_number", $('#personal_number').val());
      sessionStorage.setItem("email", $('#username').val());
      sessionStorage.setItem("password", $('#password').val());
  }
  </code></pre>
  
  <p>This "works" if I add a value to <code>personal_number</code>, <code>email</code> and <code>password</code> it gets saved to my sessionStorage and when I refresh the page, my input fields get rightly populated. </p>
  
  <p><strong>But</strong> when I go to another page (within the same website) and return back, I get <code>undefined</code> outputed in <code>personal_number</code> input field and the correct values in the others. </p>
  
  <p>I dont understand why! </p>
  
  <p>First, it should not output anything if the value is <code>undefined</code> because: <code>if (personal_number !== undefined)</code>.</p>
  
  <p>Second, how come only <code>personal_number</code> is not working and the two other fields are fine? </p>
  
  <p><strong>Update:</strong></p>
  
  <p>I removed password field since cacheing it is insecure. </p>
  
  <p>I have also figured out what is causing the problem, but I have <em>not</em> solved it. </p>
  
  <p>When I visit a page with no input fiels and return then, now, all my fields output <code>undefined</code>. So it seems like i get a new session when I do so. </p>
  
  <p>But how come it still ouputs <code>undefined</code>? </p>
  
  <pre><code>(function ($) {
      // Run on page load
      window.onload = function() {
          var person_number = sessionStorage.getItem("person_number");
          var email = sessionStorage.getItem("email");
  
          if (person_number !== undefined || person_number !== null ||
              person_number != undefined || person_number != null){
              $('#person_number').val(person_number);
          }
          if (email !== undefined || email !== null || 
              email != undefined || email != null){
              $('#username').val(email);
          }
      }
  
      // Before refreshing the page, save the form data to sessionStorage
      window.onbeforeunload = function() {
          sessionStorage.setItem("person_number", $('#person_number').val());
          sessionStorage.setItem("email", $('#username').val());
      }
  })(jQuery);
  </code></pre>
  
  <p>I know I am testing for to much, but there is no way this should output <code>undefined</code>!!</p>
  
  <p><strong>Update 2</strong></p>
  
  <p>I also updated it so it will not save inputs if the input is <code>undefined</code>/<code>null</code>. But it <strong>still</strong> does not work..</p>
  
  <pre><code>(function ($) {
      // Run on page load
      window.onload = function() {
          var person_number = sessionStorage.getItem("person_number");
          var email = sessionStorage.getItem("email");
  
          if (person_number !== undefined || person_number !== null ||
              person_number != undefined || person_number != null){
              $('#person_number').val(person_number);
          }
          if (email !== undefined || email !== null ||
              email != undefined || email != null){
              $('#username').val(email);
          }
      }
  
      // Before refreshing the page, save the form data to sessionStorage
      window.onbeforeunload = function() {
  
          var person_number = $('#person_number').val();
          var email = $('#username').val();
  
          if (person_number !== undefined || person_number !== null ||
              person_number != undefined || person_number != null){
              sessionStorage.setItem("person_number", person_number);
          }
          if (email !== undefined || email !== null ||
              email != undefined || email != null){
              sessionStorage.setItem("email", email);
          }
      }
  })(jQuery);
  </code></pre>