Is there any way to disable warnings? when i upload my portfolio to the server(on the net) it works great, that is the orgfree.com one. But when I upload it to my server of mweb,it shows the following warnings when i want to login in:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/m7713830/public_html/login.php:44) in /home/m7713830/public_html/login.php on line 93
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/m7713830/public_html/login.php:44) in /home/m7713830/public_html/login.php on line 93
Warning: Cannot modify header information - headers already sent by (output started at /home/m7713830/public_html/login.php:44) in /home/m7713830/public_html/login.php on line 95
SO line 44 is where my PHP code is starting and line 93 is where my session starts.line 95 points to my line that points to header Location: loggedin.php in the if function when the session is true.
If I do research on this topic i found that the meta char of utf 8 must change to ANSI, utf 8 is putting empty space in the beginning of the file, there's not suppose to be any empty spaces before the <?php code and that the php code MUST be ontop of the page.But i cannot put my php code on top of all the files because some pages must read my HTML code first to design the layout.
But whats also weird is the fact that on the orgfree.com server there are none of these messages and login is working perfectly(but not on my private mweb server , it looks like it can be a server issue also?
I will continue doing research.And post my solution here again for those that might come across this same prob.
All right, a little bit more info on that warning...quoted by some php forums :
"That error means you outputted something to the browser before line 93 and then tried to use a header value that can't be sent because of course the header had already been sent before line 40".
Yes my header point to another file named loggedin.php. The code on top of that file is just
so that a user cannot type the URL straight into the address bar to skip the loggin, but to take them back to the loggin page. The thing is that i cannot see that,that code can make a difference. And I'm definitely not gonna take that code out and make my site vulnerable for attacks.
Registered: 13 years ago
Session with a header redirect must be on top of the page before any other code. That is its place. If not logged in, the user should not be able to enter the page at all. No spaces there (use hard breaks to put in a new line).
You must call header() before your script produces any output e.g. echo this or print that is output.
Suppressing the error is not the way to go, because you make your code less portable (as you point out, on one server it is ok on another it is. I'll trust the server that gives an error). Orgfree is sort of gong happy lucky, but then you don't pay for it, also meaning you ill not get the best.
Just want to give the solution, yes the problem here was with the PHP code. It was suppose to be on top of all the other code(before html).There should not even be any html or css code before the PHP code.Problem solved.