title: redirect user if not logged in in html with jquery
body: <p>I want to redirect not logged user to Login.html  if they are not logged in and try to browse my Startpage. I am using cookies and used this code: </p>
  
  <pre><code>$(document).ready(function () {
  
          if(Cookies.get('user') == undefined) {
           window.location.replace("http://localhost/login.html");
           //window.location.href = "http://localhost/login.html";
           //$(location).attr('href', 'http://localhost/login.html');
          }
      });
  </code></pre>
  
  <p>The Problem is that the browser shows for a half second the Startpage and redirect afterwards.</p>
  
  <p>Is it possible not showing the Startpage at all? Or is it only possible with PHP-Sessions</p>
  
  <pre><code>if(!isset($_SESSION["username"]))
  {
  header("location:login.html");
  exit;
  }
  </code></pre>