$_SESSION is a special array used to store information across the page requests a user makes during his visit to your website or web application.
Starting a Session and Storing a value in Session
Before you can to store information in a session, you have to start PHP’s session handling. To start the session session_start() is used -
// start them engines!
// store session data
$_SESSION["username"] = "QueryHome";
session_start() starts the session between the user and the server, and allows values stored in $_SESSION to be accessible in other scripts later on.
Retrieving a Session Variable
You call session_start() again which continues the session in another file and you can then retrieve values from $_SESSION.
// continue the session
// retrieve session data
echo "Username = " . $_SESSION["username"];
Ending a Session Variable
To delete a single session value, you use the unset() function:
// delete the username value
Ending all the session variable
To unset all of the session’s values, you can use the session_unset() function:
// delete all session values