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!
Everything seems to work ok on my home server but when I upload i am getting this error
'
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/html/test/longscarves.php:2) in /var/www/html/test/longscarves.php on line 3
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/html/test/longscarves.php:2) in /var/www/html/test/longscarves.php on line 3'
Does anyone know why this is happening and how i deal with it?
If you do a search for "headers already sent" on these forums you should find your answer. In brief however session_start() should be before you output anything (even a blank line before <?php will cause the error).
nutstretch wrote:I have a website i am working on which requires sessions. i ahve put the seeions at the top of the pages that require the information.
Everything seems to work ok on my home server but when I upload i am getting this error
'
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/html/test/longscarves.php:2) in /var/www/html/test/longscarves.php on line 3
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/html/test/longscarves.php:2) in /var/www/html/test/longscarves.php on line 3'
Does anyone know why this is happening and how i deal with it?
Thanks in anticipation
nuts
Yes - the problem is caused by whitespace before your opening <?php tag.
thanks for the code sugesstion. I have checked the files and there is no space before the <?PHP.
the page it is happening on is one where the page deletes the selected item from the database and then sends the user back to the shopping cart which should then refresh.
the error i am getting is
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/test/delete.php:16) in /var/www/html/test/delete.php on line 32
I have looked through the forum and all i could find was info about space before the session etc.
This was to retrieve the session information to use on the next pages.
However i had a page where i had 'session_start()' before the 'session_id()' and this brought up the same sort of error. I'm presuming it is trying to start another session within a session??
Don't know if it will help, but it could be worth looking out for...
Thanks I took out all that html rubbish as i realised it didn't need to be there as it was just redirecting after anyway and it worked without the warning.