Sessions for newbies example

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cooler75
Forum Commoner
Posts: 40
Joined: Wed May 29, 2002 2:43 pm
Location: RichIsland

Sessions for newbies example

Post 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
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post 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
Post Reply