I'm trying to create a session where the user is required to be logged in before accessing a page. Essentially I want them to be alerted that they need to be logged in before re-directing them to the login page.
<html>
<body>
<?php
if (isset($_SESSION['username'])) {
$username = $_SESSION['username'];
echo "<p>Username: $username</p>\n";
} else {
header('Location: login_home.html');
echo "<script type='text/javascript'>alert('Please login to view this page')</script>";
}
?>
</body>
</html>
At the moment it is just re-directing without alerting any information.