How can we register the variables into a session?
A session is a simple and effective way to store information. It works primarily like cookies, where user information is saved. However, unlike a cookie, the information is not stored on the user’s computer, but rather on the server thus making the data safer.
In order for the information to be saved, a session must be started. A new session can be started by using the session_start() function.
A variable can be registered into a session using the $_SESSION function.
<?php // Starting session session_start(); // Storing session data $_SESSION["firstname"] = "Peter"; $_SESSION["lastname"] = "Parker"; ?>