Having a file that only auth people can see. And trying to redirect other users before page loads. Following method permits page to load which i do not want.
<?php
session_start();
// Check if person is logged in
if($_SESSION['login'] != 'true'){ //if login in session is not set
echo "<script>
window.location = 'index.php';
</script>";
}
?>
Edit Working Version.
<?php
session_start();
// Check if person is logged in
if($_SESSION['login'] != 'true'){ //if login in session is not set
header('Location: index.php');
exit;
}
?>
P.S. Thanks.