Session variables are superglobals that allow you to pass things between php files.
When to use
Anytime you have data that you want to pass from file to file, you can use Session Variables.
To create a Session, use the session_start function:
You need to do that for every page of your app that needs to use session variables.
To create a session variable:
$_SESSION["fav_pizza"] = "pepperoni";
To access that session variable:
Hints & tips
- Session Variables are superglobals
- session_start(); //start a session
- $_SESSION["variable_name"] = "Data you want to save";
Lesson notes are only available for subscribers.