How can PHP sessions be effectively utilized to maintain login status across multiple pages without relying on cookies?

To maintain login status across multiple pages without relying on cookies, PHP sessions can be effectively utilized. By storing the user's login information in session variables, the login status can be maintained throughout the user's browsing session without the need for cookies.

<?php
session_start();

// Check if the user is logged in
if(isset($_SESSION['user_id'])) {
    // User is logged in
    echo "Welcome, ".$_SESSION['username']."!";
} else {
    // User is not logged in
    echo "Please log in to access this page.";
}
?>