Session in PHP
⟼ PHP session is used to store and pass information in variables to be used across multiple pages.:
⟼ In PHP session creates unique user id for each browser to recognize the user and avoid conflict between multiple browsers.
You can see example of shopping website where store username, product code, product name, product price etc.
How Session Works
Start Session in PHP
In PHP in-built a function named as session_start() this function starts a new or resumes existing session.It returns existing session if session is created already. If session is not available, it creates and returns new session..
$_SESSION is used to set and get session variable values.
File name :- session1.php
File name :- session2.php
Session Counter Example in PHP
File name :- SessionCounter.php
PHP Session Destroy
session_destroy() funtion is used to destroy all session.