How sessions work in PHP
📖 Scenario: You are building a simple website that remembers a visitor's name during their visit. This helps the site greet them personally on each page.
🎯 Goal: Create a PHP script that starts a session, saves a visitor's name in the session, and then retrieves and displays that name on the page.
📋 What You'll Learn
Start a PHP session using
session_start()Create a session variable called
user_name and assign it the value 'Alice'Retrieve the
user_name from the sessionDisplay a greeting message using the session value
💡 Why This Matters
🌍 Real World
Sessions help websites remember who you are as you move between pages, like keeping your shopping cart or login info.
💼 Career
Understanding sessions is key for web developers to manage user data securely and create personalized experiences.
Progress0 / 4 steps