How can we create a session in php?

PHP session is a way to store information to be used across multiple pages. A session is started with the session_start() function. Session data is stored in the PHP global variable: $_SESSION.

Example to create a PHP SESSION

// Start the session
// Set session variables
$_SESSION["name"] = "robin";
$_SESSION["fav_color"] = "green";
echo "Session variables are set: ".$_SESSION["name"]." ".$_SESSION["fav_color"];

Learn more about the similar topics:
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.