How can a PHP script be used to limit a user to accessing a page only once?

To limit a user to accessing a page only once, you can use a session variable to track whether the user has already visited the page. If the session variable is set, the user will be redirected away from the page. If not, the session variable will be set to prevent further access.

<?php
session_start();

if(isset($_SESSION['visited'])) {
    header('Location: another_page.php');
    exit();
}

$_SESSION['visited'] = true;
?>