To use session variables you have to first start your session by using function session_start();. Once you have started your session you can use vriables similar to $_GET and $_POST.
For example, to create a session variable called "username" you would:
session_start();
$_SESSION["username"] = $uname;
After you have declared your session variables, you can use them as long as the user does not close their browser.
Given this you would ideally create your session variables after the user logs in, and then use them on every page thereafter so you can customize the user experience based on their user credentials. For exanple, at the beginning of every page you can check and see if their is a session variable defined for user name, and if there is not then you can display the login page:
session_start();
if ($_SESSION["username"]{
...
...
});
NOTE: To use session variables on your page you need to specify session_start();, otherwise you will loose the sessions.
NOTE: It is best practice to define your <?php ... ?> on top of your page, and more sore when using session variables. Not doing so may cause unexpected outcome.
NOTE: If you want the session to persist even after you close your browser then you have to use cookies.