Why is my php session not working?

Sessions in PHP allow you to preserve user data across multiple pages.

Example:


  $_SESSION['username'] = 'JohnDoe';
  

Solution:


  session_start();
  $_SESSION['username'] = 'JohnDoe';
  

Beginner's Guide to PHP