0Pricing
PHP Academy · Lesson

Starting and Using Sessions

Start a session with session_start and store data in _SESSION.

What Are PHP Sessions?

HTTP is stateless. PHP sessions persist data across multiple requests by storing data server-side and referencing it via a session ID cookie.

session_start()

Call session_start() before any output. It either resumes an existing session or creates a new one.

<?php
session_start();
// Must be called before any echo/HTML output

All lessons in this course

  1. Starting and Using Sessions
  2. Session Security Best Practices
  3. Setting and Reading Cookies
  4. Cookie Security: HttpOnly and Secure Flags
← Back to PHP Academy