if ($user = getLogin()) { echo "Welcome, $user!"; } else { echo "Please log in to continue."; }
if (!getLogin()) { header("Location: login.php"); exit; }This code checks if there is a logged-in user. If not, it redirects the user to a login page. getLogin is a built-in PHP function and does not require any additional package or library.