What are PHP sessions and how do they work?
Roshan Rathod
It is way to store information (in variables). In order they are available in multiple pages for the same web application.
Example:
<?php// Start the sessionsession_start();?><!DOCTYPE html><html><body><?php// Set session variables$_SESSION["favcolor"] = "green";$_SESSION["favanimal"] = "cat";echo "Session variables are set.";?></body></html>
<?php
// Start the session
session_start();
?>
<!DOCTYPE html>
<html>
<body>
// Set session variables
$_SESSION["favcolor"] = "green";
$_SESSION["favanimal"] = "cat";
echo "Session variables are set.";
</body>
</html>