Recall & Review
beginner
What is a session in PHP?
A session in PHP is a way to store information (variables) to be used across multiple pages by the same user. It helps keep data like login status or preferences while the user browses the website.
Click to reveal answer
beginner
How does PHP identify a user session?
PHP uses a unique session ID stored in a cookie on the user's browser. This ID links the user to their stored session data on the server.
Click to reveal answer
beginner
What function starts a session in PHP?
The function session_start() starts a new session or resumes an existing one. It must be called before any output is sent to the browser.Click to reveal answer
intermediate
Where does PHP store session data?
PHP stores session data on the server, usually in temporary files. The session ID in the user's cookie tells PHP which data belongs to that user.
Click to reveal answer
beginner
How do you store and access session variables in PHP?
Use the $_SESSION superglobal array. For example, $_SESSION['username'] = 'Alice'; stores data, and you can access it later with $_SESSION['username'].
Click to reveal answer
Which PHP function is used to start or resume a session?
✗ Incorrect
The correct function to start or resume a session in PHP is session_start().
Where is the session ID usually stored on the client side?
✗ Incorrect
PHP stores the session ID in a cookie on the user's browser by default.
What superglobal array holds session variables in PHP?
✗ Incorrect
Session variables are stored in the $_SESSION array.
When must session_start() be called in a PHP script?
✗ Incorrect
session_start() must be called before any output to avoid errors.
Where is session data stored in PHP?
✗ Incorrect
Session data is stored on the server, linked by the session ID.
Explain how PHP uses sessions to remember user information across pages.
Think about how PHP links a user to their data using a unique ID.
You got /5 concepts.
Describe the steps to store and retrieve a username using PHP sessions.
Remember the order and the special array used.
You got /3 concepts.