To store values into the container we mostly use the variable , while the variables have maximum scope to the current page only . So we use sessions to pass the values from one page to another in hidden format. We can also pass the values from one page to anther in the URL parameters GET and POST but security purposes we choose the PHP SESSION . There is no need to pass the sessions from one page to another page again and again. We just set the sessions value one time then we can easily fetch this value from any where within the current host server/domain.
session_start();
$_SESSION['sessionName'] = 'Some Value';
Remember that it is compulsory to call the session_start() function on the page where we want to set and get the SESSION value.
session_start();
$_SESSION['username'] = 'Codingpk'; // SESSION SET
echo $_SESSION['username']; // SESSION GET
session_destroy(); // Destroy Function
OR
unset($_SESSION['username']); // Destroy individually