I have a PHP page with an HTML form that checks a users username and password using a MySQL connection, and if they are correct stores them in the $_SESSION cookie. Then the browser is redirected to the home page 'index.php' where the $_SESSION variables are successfully retrieved and the user is shown as logged in.

However, when I move to another PHP page that uses exactly the same code to access $_SESSION, it cannot find the variables. If I go back to 'index.php', and even refresh the page, it still says logged in. Another website I've built (same server, different directory) functions fine using $_SESSION.

What the hell is going on? Cookies are definitely enabled, $_SESSION is definitely being set, all pages have 'session_start();' but I can only get to it from one webpage.

Any help much appreciated - this is doing my head in!!