Recall & Review
beginner
What is a session in PHP?
A session in PHP is a way to store data on the server for a user to use across multiple pages. It keeps user information safe and private during their visit.
Click to reveal answer
beginner
What is a cookie in PHP?
A cookie is a small piece of data stored on the user's browser. It helps remember information like login or preferences even after the browser is closed.
Click to reveal answer
intermediate
When should you use a session instead of a cookie?
Use a session when you need to store sensitive data securely on the server or when data should not be visible or modifiable by the user.
Click to reveal answer
beginner
What are the size limits for cookies?
Cookies are limited to about 4KB of data per cookie, so they are not suitable for storing large amounts of information.
Click to reveal answer
intermediate
How does a session maintain user state differently from a cookie?
A session stores data on the server and uses a session ID cookie to link the user. Cookies store all data on the user's browser directly.
Click to reveal answer
Which of the following stores data on the server side?
✗ Incorrect
Sessions store data on the server, while cookies and local storage store data on the client side.
What is the typical size limit for a cookie?
✗ Incorrect
Cookies are limited to about 4KB of data per cookie.
Which is safer for storing sensitive user data?
✗ Incorrect
Sessions keep data on the server, making them safer for sensitive information.
If you want to remember a user's preference after they close the browser, what should you use?
✗ Incorrect
Cookies can persist data on the user's browser even after closing it.
How does a session identify a user?
✗ Incorrect
Sessions use a session ID cookie to link the user to their server-stored data.
Explain the main differences between sessions and cookies in PHP.
Think about where data is stored and how long it lasts.
You got /4 concepts.
Describe a scenario where using a session is better than a cookie.
Consider when you want to keep data hidden from the user.
You got /4 concepts.