session_start(); $username = $_SESSION['get_user']; echo "Welcome, $username!";
session_start(); if (isset($_SESSION['get_user'])) { // user is logged in, continue } else { // user is not logged in, redirect to login page header("Location: login.php"); exit(); }This code checks if the "get_user" session variable is set, which indicates that the user is logged in. If it is not set, the user is redirected to the login page. The session handling functions in PHP are included in the core library, so no separate package library is required.