Recently I was creating a new website from scratch, which required authentication and the use of PHP’s sessions functionality. I used the session to store information which I needed to be persistent between pages:

Page 1

Page 2

However page 2 would never display the user ID value. I couldn’t work out what was causing the problem. The solution is to make sure you include session_start() at the top of ever page you need to access the $_SESSION super global array.