-1

Is there any specific way to turn off PHP warnings in cPanel? Or is there a way to disable PHP warnings using code? The reason for this question is following error,

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/fteeloco/public_html/login_process.php:1) in /home/fteeloco/public_html/login_process.php on line 2

The reason for this error is (as I think ) adding white space before the PHP start tag. Please help.

cmit
  • 261
  • 2
  • 7
  • 15
  • 2
    It would make more sense to [fix the error instead of hiding it](https://twitter.com/moo9000/status/260819671505334272)... – DCoder Nov 03 '14 at 10:18
  • If I remove white spaces then it works normally. But problem is cPanel add white space automatically later. – cmit Nov 03 '14 at 10:20
  • you can refer this link http://forum.arvixe.com/smf/general/turn-off-display_errors-with-whmcpanel/ –  Nov 03 '14 at 10:21
  • possible duplicate of [PHP error: Cannot modify header information – headers already sent](http://stackoverflow.com/questions/1793482/php-error-cannot-modify-header-information-headers-already-sent) – Rakesh Sharma Nov 03 '14 at 10:22

3 Answers3

0

Move the session_start() in first line of your page. Error will be resolved.

Note: Add it in header file if you you have header (eg: header.php) file separately. Remove from login_process.php

Asik
  • 7,967
  • 4
  • 28
  • 34
0

Add session_start() to the start of php pages where you are using Session variables (if not added).

Sougata Bose
  • 31,517
  • 8
  • 49
  • 87
0

I want to start by saying that: you are wrong! That is not the reason that you see that warning. The reason is that you started the session before, and then you started it again. So look in your code for 2 lines with "session_start()". Even if this is not right, session_start() must be the first line in your script!!!

Now to answer your question!

There are 2 ways to do this:

  1. disable warnings from php.ini

    Open PHP.ini file.

    In this file search for the phrase “ error_reporting = E_ALL” ,[without inverted commas]

    Here replace this with “error_reporting = E_ALL & ~E_NOTICE & ~E_WARNING “

    (Show all errors, except for notices and coding standards warnings)

    Make sure you change the real enabled part of this , there are certain other examples given in the file.

    Restart your PHP + Apache

  2. use the error_reporting() function in PHP like is described in the PHP manual HERE

But I must warn you, nither of this are considered good practice. It is not ok to disable warning, notice or error messages.

Hope this helps! :D

Ares Draguna
  • 1,641
  • 2
  • 16
  • 32
  • wow, spellcheck. Also you are wrong. You should always disable error reporting for production. This is very basic. – Kevin Compton May 19 '16 at 21:26
  • There was no talk about production / development stages of his application. More so, he explicitly asked for a way on how to turn off errors. And what is with the "wow, spellcheck" ?? :)) I am not getting this... – Ares Draguna May 23 '16 at 07:20
  • Obviously he wants them off for production. – Kevin Compton May 23 '16 at 18:05
  • Why is it so obvious? :) Do you really think that someone who asked that kind of question is making a production-level project? If so, then you are right... but I highly doubt it :D ... and what about that "wow, spellcheck" thing? :) I still don't get it :D – Ares Draguna May 25 '16 at 08:09
  • It's incredible to me, the ratio... of douche bags.. on this site – Kevin Compton May 26 '16 at 22:00