How cookies work
📖 Scenario: You are building a simple website that remembers a visitor's name using cookies. When the visitor enters their name, the website saves it in a cookie so that next time they visit, the site greets them by name automatically.
🎯 Goal: Create a PHP script that sets a cookie with the visitor's name, reads the cookie on subsequent visits, and displays a greeting message using the stored name.
📋 What You'll Learn
Create a variable to hold the visitor's name
Set a cookie with the visitor's name that expires in 1 hour
Check if the cookie exists and read the visitor's name from it
Display a greeting message using the visitor's name from the cookie
💡 Why This Matters
🌍 Real World
Cookies are used by websites to remember users and their preferences, making visits more personal and convenient.
💼 Career
Understanding how cookies work is important for web developers to manage user sessions, preferences, and authentication.
Progress0 / 4 steps