I am new to php and have been working on setting up a website with certain pages password protected. I have a user registration form saving the information on mysql which seems to work fine and when I launched the login/registration part of my website it seemed to work fine for the first 24 hours (with over 100 users registering).
After this initial period it just stopped working - the registration is still working and new users can been added but the first of the password protected pages won’t load.
This is the php script that I have to check for the session variable being set before loading the page or redirecting to the page called assess.php where the user is asked to login or register
<?php
session_start(); // Start the session.
if (!isset($_SESSION['username'])) {
(header("Location: assess.php"));
exit(); // Quit the script.
}
?>
Nothing seems to happen - it just shows a blank page where as initially it all worked fine.
Any suggestions - what am I missing?
Thanks in advance
The following code is at the top of the password protected page…before the html
[php]<?php
ini_set(‘display_errors’,1);
ini_set(‘display_startup_errors’,1);
error_reporting(-1);
session_start();
if (!isset($_SESSION[‘username’])) {
(header(“Location: assess.php”));
exit(); // Quit the script.
}
?>
SASSMAIN
[/php]
Plus just realised that I had put your suggested reporting code after the session start…the error messages now look like this
[php]Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /www/sites/f91/56e/test.mathsbox.org.uk/web/sass.php:1) in /www/sites/f91/56e/test.mathsbox.org.uk/web/sass.php on line 5
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /www/sites/f91/56e/test.mathsbox.org.uk/web/sass.php:1) in /www/sites/f91/56e/test.mathsbox.org.uk/web/sass.php on line 5
Warning: Cannot modify header information - headers already sent by (output started at /www/sites/f91/56e/test.mathsbox.org.uk/web/sass.php:1) in /www/sites/f91/56e/test.mathsbox.org.uk/web/sass.php on line 7[/php]