Session variables hold information about one single user, and are available to all pages in one application. When we work with an application, we open it, do some changes and then we close it. This is much like a Session. The computer knows who you are. It knows when you start the application and when you end.
But on the internet there is one problem: the web server does not know who you are and what you do because the HTTP address doesn’t maintain state (HTTP is a stateless protocol).
A PHP session solves this problem by allowing us to store user information on the server for later use (i.e. username, shopping items, etc).
However, session information is temporary and will be deleted after the user has left the website. If one needs a permanent storage he/she may want to store the data in a database.
Starting a PHP Session
<?php
session_start(); ?>
<html> <body> </body> </html>