What are the potential pitfalls of using cookies or sessions to control page access in PHP?

One potential pitfall of using cookies or sessions to control page access in PHP is that they can be easily manipulated by users. To mitigate this risk, it is important to validate the user's access rights on the server-side before granting access to restricted pages.

// Validate user access rights on the server-side
session_start();

if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true) {
    header("Location: login.php");
    exit;
}