Locked lesson.
About this lesson
Exercise files
Download this lesson’s related exercise files.
Sessions.docx59.1 KB Sessions - Solution.docx
59.2 KB
Quick reference
Sessions
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.
Instructions
To create a Session, use the session_start function:
session_start();
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:
echo $_SESSION["fav_pizza"];
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.