title: JavaScript Prevent accessing restricted page without login in
body: <p>I have a login page after being logged to page I move to my next-page (welcome).
  The problem is that if I copy and paste the URL of the next-page (welcome) my page also open, I want to restrict to open the next page without login access.
  Guide me What to do.</p>
  
  <p>Script</p>
  
  <pre><code>function click() {
      inputname = $('#name').val();
      inputpassword =$('#pass').val();
  
      for (i in data.username )      //to match username with provided array
        { 
          name = data.username[i];
  
          for ( i in data.password){
              pass = data.password[i];
  
              if (inputname == name &amp; inputpassword == pass ){
                  window.open('welcome1.html','_self');
              }               
          }
      }
  
      if (inputname != name &amp; inputpassword != pass ){
          alert("Wrong Password");
      }
  }
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>&lt;input type="mail" id="name"&gt;
  &lt;input type="password" id="pass"&gt;
  &lt;input type="submit" id="submit" value="log In" onclick= "click()"&gt;
  </code></pre>