session_start(); // start the session if (isset($_SESSION['user']) && $_SESSION['user']['is_admin']) { // the user is an admin, perform admin tasks } else { // the user is not authorized to perform admin tasks }
if ($user->is_admin) { // display admin-only content } else { // display regular content }This attribute is often used in conjunction with a user management package library, such as Laravel's built-in authentication package or the popular third-party package, Sentry.