Possible Duplicate:
Headers already sent by PHP
The following code in PHP gives the warning.
<?php
if(!isset($_SESSION))
{
session_start(); // line 4
}
if(!isset($_SESSION['valid_admin']))
{
header("location:Login.php"); //line 9
}
?>
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\wamp\www\wagafashion\Order.php:8) in C:\wamp\www\wagafashion\Lock.php on line 4
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\wagafashion\Order.php:8) in C:\wamp\www\wagafashion\Lock.php on line 4
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\wagafashion\Order.php:8) in C:\wamp\www\wagafashion\Lock.php on line 9
I searched on Google and found a question here but I by far don’t understand what is mentioned there. How could I solve it?
[My application with the above code was working fine but a few days ago the system crashed with the blue screen error and I had to reinstall it where I installed a different version of WAMP. Is this the problem?]
Session will never be set in that if statement unless you call session_start()
If you call session_start() before the if statement (like you should be doing) your condition will always be true, rendering the if statement useless.
So you can place session_start() above the first if statement and then delete the first if statement.