Page 1 of 1

Sessions for newbies example

Posted: Wed May 29, 2002 2:43 pm
by cooler75
Hi,
I was reading Jason's session for newbies article on this site and did the example he gave and found out that there was an error,


After I loaded sessiontest.php, I got this error message:


Warning: Cannot send session cache limiter - headers already sent (output started at c:\program files\apache group\apache\htdocs\learn\sessiontest.php:1) in c:\program files\apache group\apache\htdocs\learn\sessiontest.php on line 3
Current Session Number Count: $num[count]

Here is my question, I have seen quite a bit of this happen when installing other scripts. Can someone explain to me why it's given this error message?

Thank you

Posted: Wed May 29, 2002 4:34 pm
by hob_goblin
you cant output headers if something else is already being set, for instance a bit of html is printed, you can't do that

for instance:

Code: Select all

<?php
header("Location: somewhere");
?>
would not work -- there is a extra line break at the top, this counts as outputting something

Code: Select all

<html>
<?php
header("Location: somewhere");
?>
would not work -- stuff is being outputted

Code: Select all

<?php
echo "something";
header("Location: somewhere");
?>
ditto, you get the point