session_start(); // start the session unset($_SESSION['username']); // delete a specific session variable session_destroy(); // destroy all session data
session_start(); // start the session $_SESSION = array(); // clear all session variables session_destroy(); // destroy all session dataIn this example, the `$_SESSION` superglobal is set to an empty array to clear all session variables. The `session_destroy()` function is used to destroy all session data. Package library: Session handling in PHP is native and does not require any external library or package.