How can PHP sessions be utilized to differentiate between normal users and administrators in a registration system?

To differentiate between normal users and administrators in a registration system using PHP sessions, you can set a session variable during the login process that identifies the user's role. This session variable can then be checked on subsequent pages to determine the user's privileges.

// During the login process
if ($username == 'admin' && $password == 'adminpass') {
    $_SESSION['role'] = 'admin';
} else {
    $_SESSION['role'] = 'user';
}

// On subsequent pages
if ($_SESSION['role'] == 'admin') {
    // Code for administrators
} else {
    // Code for normal users
}