A session variable is used to store some useful data and that data is accessible from every page. In PHP $_SESSION is a pre-defined variable, this variable is used to store different values, which are accessible from any page of the website.
When we develop an application (website etc.), user access it, do their tasks and close it. It is a Session. A computer could know us, but on the Internet the web server does not know who we are and what we do because the HTTP is a stateless protocol.
A session helps us to fix this problem by allowing us to store useful data on the server. Data stored in session is temporary and deleted after the user has left the website.
Session produces a unique id (UID) for each visit and we may take reference of it as per requirement. The session_start() function must appear at the beginning of coding (before html).
session_start();if(isset($_SESSION))$_SESSION['view']+=1; else $_SESSION['view']=1; echo "Total no. of view is:".$_SESSION['view'];
Total no. of view is:3
Recommend the tutorial