Recall & Review
beginner
What is a cookie in web development?
A cookie is a small piece of data stored on the user's computer by the web browser. It helps websites remember information about the user, like login status or preferences.
Click to reveal answer
beginner
How does a server send a cookie to a browser in PHP?
The server sends a cookie using the
setcookie() function before any output is sent. This function sets the cookie name, value, and optional parameters like expiration time.Click to reveal answer
beginner
Where are cookies stored and how are they sent back to the server?
Cookies are stored in the user's browser. When the browser makes a request to the same server, it sends the stored cookies automatically in the HTTP headers.
Click to reveal answer
beginner
What is the purpose of the cookie expiration time?
The expiration time tells the browser how long to keep the cookie. If no expiration is set, the cookie lasts only for the browser session and is deleted when the browser closes.
Click to reveal answer
beginner
How can you access a cookie value in PHP?
You can access cookie values using the
$_COOKIE superglobal array with the cookie's name as the key, for example, $_COOKIE['username'].Click to reveal answer
Which PHP function is used to send a cookie to the browser?
✗ Incorrect
The correct function to send a cookie in PHP is
setcookie().Where are cookies stored after being sent by the server?
✗ Incorrect
Cookies are stored on the user's browser and sent back to the server with each request.
What happens if you don't set an expiration time for a cookie?
✗ Incorrect
Without an expiration time, the cookie lasts only for the current browser session.
How do you access a cookie named 'user' in PHP?
✗ Incorrect
Cookie values are accessed using the
$_COOKIE array with the cookie name as the key.When must you call
setcookie() in a PHP script?✗ Incorrect
Cookies must be sent before any output because they are part of HTTP headers.
Explain how cookies are created, stored, and sent back to the server in PHP.
Think about the journey of a cookie from server to browser and back.
You got /4 concepts.
Describe the role of cookie expiration time and what happens if it is not set.
Consider how long the cookie stays on the user's device.
You got /3 concepts.