Question

This problem occurs on a Chromebook. Basically, my PHP session variables are not working consistently. Whilst attempting to narrow down this problem, I wrote a small script to check that the Session variables work at all. Script is as follows:

<?php
  session_start();
  if (isset($_SESSION['variable'])) {
    echo $_SESSION['variable'];
  } else {
    echo "EMPTY";
  }
  $_SESSION['variable'] = time();
?>

The script simply displays 'Empty' the first time it is executed, because there's no stored variable. However, as expected, when the page is refreshed, the time stamp of the last execution is displayed.

So, the session variables worked, so I went back and checked on the main project. Suddenly, the entire project was working perfectly, without any coding changes to the project. This phenomenon has happened three times, where the main project doesn't work, then the separate "time stamp" script is executed, and suddenly the main project has started working.

To clear things up: This is not the favicon.ico bug, there's one of those already in the root of the server.

My main project is located here (too big for the entire question, it's around 400 lines): http://pastebin.com/FJAkXqdz

Any help would be appreciated. Thanks in advance for your time.

Was it helpful?

Solution

Your file has a HTML comments before <?php session_start();. You have to call session_start() before you produce any output. So change it to:

<?php session_start(); ?>
<!-- Created by Caleb Power
     Updated January 10, 2014
     Intended use for only the Epsilon Sigma Chapter of Tau Kappa Epsilon -->
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top