一旦注销,阻止用户进入

So I designed a log in system. However when ever the user logs in I redirect him to a new page where there is a menu. But when ever the user logs out and copies the home page URL. He is capable of coming back again. How do I prevent this?

Login.php

<html>

<head>
  <title>Log in</title>
</head>

<body>
  <h1>Welcome please sign in!</h1>

  <?php if (!isset($_POST[ 'submit'])){ ?>
  <!-- The HTML login form -->
  <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
    Username:
    <input type="text" name="username" />
    <br />Password:
    <input type="password" name="password" />
    <br />

    <input type="submit" name="submit" value="Login" />
  </form>
  <?php } else { require_once( "db_const.php"); $mysqli=n ew mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); # check connection if ($mysqli->connect_errno) { echo "
  <p>MySQL error no {$mysqli->connect_errno} : {$mysqli->connect_error}</p>"; exit(); } $username = $_POST['username']; $password = $_POST['password']; $sql = "SELECT * from users WHERE username LIKE '{$username}' AND password LIKE '{$password}' LIMIT 1";
  $result = $mysqli->query($sql); if (!$result->num_rows == 1) { echo "
  <p>Invalid username/password combination</p>"; } else { echo '
  <script language="javascript">
    ';
        echo '
    alert("Log in successfull!")
    ';
        echo '
  </script>'; header( "refresh:5;url=home.php" ); } } ?>
</body>

</html>

Logout:

<?php
session_start();
session_destroy();
header('Location: login.php');
exit;
?>

And the menu page:

<a href="login.php">Logout</a>

</div>

Try this code and put in home page in top.

if(!isset($_SESSION['username'])) {
   header("Location: login.php");
   exit;
}