Sessions are data structures that provide a way to store user-specific data and associate it with a unique session ID. However, PHP sessions also solve the following problems.
A session creates a file in a temporary directory on the server to cache the registered session variables and their values. This data will be accessible to all pages on the site during that stay.
PHP uses a php.ini file to get hold of the server settings. This file also specifies the location of the session file under the <session.save_path>. The developers can make sure that this setting points to a correct value before using the session variable.
PHP Session Lifecycle.

While building up a session following events happen.
1. PHP generates PHPSESSID such as “c69dc153f003406b9a0242ad4c505baa”.
2. The PHP engine creates a file for every new session at the designated location. It bears the name of the unique identifier prefixed by <sess_>.
e.g. sess_c69dc153f003406b9a0242ad4c505baa.
3. When PHP gets a request from the browser or a client to access the session variable, it retrieves the session string from the PHPSESSID cookie.
4. A session comes to an end if the user decides to close the browser. However, the server could also terminate it after a certain inactivity period.