session_start(); // start or resume existing session if (isset($_SESSION['user_id'])) { // user is logged in } else { // user is not logged in }This code starts the session, and then checks if the "user_id" key exists in the session. If it does, the user is considered to be logged in. The getSession function is part of the PHP Core library, and does not require any additional package libraries.