I'm trying to check if the user hasnt logged in on a cart.php, if they arent -redirect them to login.php.
This isn't working so I tried putting it in an elseif statement. If they are logged in and are on the cart page, redirect them to the cart page, and if they arent redirect them to the login page.
It is working in the sense that it redirects, yet if I login, it still redirects to login.php.
Also I'm not sure why none of the JS alerts are working.
if (isset($_SESSION['username'])){
header("Location: http://localhost/techiteasy/cart.php");
}
else if (!isset($_SESSION['username'])){
header("Location: http://localhost/techiteasy/login.php");
echo '<script language="javascript">';
echo 'alert("Please Login/Register")';
echo '</script>';
}