Session¶
Session support in PHP consists of a way to preserve certain data across subsequent accesses to the web server.
By default, each query to a webserver is indenpendant from the others. With session, it is possible to keep some data on the server, and retrieve them at each access.
It relies on the session_*
functions, and the $_SESSION
superglobal variable.
<?php
if (isset($_SESSION['x'])) {
print "x was already set with the value ".$_SESSION['x'];
}
$_SESSION['x'] = rand(0, 10);
print "Giving the value ".$_SESSION['x']." to x, in the session\n";
?>
See also Session in PHP: Creating, Destroying, and Working With Session in PHP, https://phpforever.com/php/fixing-php-session-issues-troubleshooting-and-solutions/
Related : Superglobal Variables