Sessions allow you to persist data across multiple HTTP requests for a single user. PHP stores session data on the server and sends a session ID to the browser via a cookie (PHPSESSID by default).
- Call
session_start()at the very beginning of every page that uses sessions — before any output. - Store and read data via the
$_SESSIONsuperglobal array. - Use
session_destroy()to end a session (e.g., on logout).