Having a problem with sessions which is becoming very annoying. Every time I try to start a session on a particular page I get the following error:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at ............ on line 23
using this code:
<?php
session_start();
if(isset($_SESSION['user']))
{
$user = $_SESSION['user'];
echo "$user";
}
else
{
}
?>
Is it suggesting I've already used session_start();
? Ive had a look around but nothing really clears this up for me.
Thanks
"Headers already sent" means that your PHP script already sent the HTTP headers, and as such it can't make modifications to them now.
Check that you don't send ANY content before calling session_start
. Better yet, just make session_start
the first thing you do in your PHP file (so put it at the absolute beginning, before all HTML etc).