// Start a new session session_start(); // Store user data in session variables $_SESSION["username"] = "John"; $_SESSION["age"] = 30; // Retrieve and output session data echo "Username: " . $_SESSION["username"]; echo "Age: " . $_SESSION["age"];
// Start the session session_start(); // Remove all session variables session_unset(); // Destroy the session session_destroy();In this example, we are destroying the current session and removing all session variables. The PHP Session functions are part of the core PHP library and do not require any external packages or libraries.