// Start the session session_start(); // Add some values to the session $_SESSION['name'] = 'John'; $_SESSION['age'] = 35; // Remove the 'age' value from the session session forget('age'); // Display the remaining Session variables var_dump($_SESSION);
// Start the session session_start(); // Add some values to the session $_SESSION['cart'] = array( 'item1' => 'Shirt', 'item2' => 'Pants', 'item3' => 'Socks' ); // Remove the 'item2' value from the 'cart' session variable session forget('cart.item2'); // Display the remaining Session variables var_dump($_SESSION);In this example, an array is added to the session under the variable name 'cart'. Then, the forget() function is called to remove the 'item2' value from the 'cart' array. Finally, the remaining Session variables are displayed using var_dump(). The package/library that provides this function is the PHP core language.