0
0
PHPprogramming~5 mins

Session vs cookie decision in PHP - Quick Revision & Key Differences

Choose your learning style9 modes available
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?
ALocal Storage
BCookie
CSession
DURL Parameters
What is the typical size limit for a cookie?
A4KB
B1MB
C100KB
DNo limit
Which is safer for storing sensitive user data?
ASession
BCookie
CLocal Storage
DAll are equally safe
If you want to remember a user's preference after they close the browser, what should you use?
AServer variable
BCookie
CSession
DTemporary file
How does a session identify a user?
ABy using IP address only
BBy storing user data in the URL
CBy saving data in local storage
DUsing a session ID stored in a cookie
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.