So many questions are there regarding "Headers already sent-cannot modify" but no answer works. I figured out one solution i.e. changing php version in cPanel solves the problem temporarily but i dont know how to solve this permanently. we cant keep changing php version time and again.
Asked
Active
Viewed 487 times
1
-
Both the problem and the fix are rather straightforward so I'm really cautious about your statement that no answers found in Stack Overflow work. If switching PHP versions works for you it's by pure chance: the installations have different settings or you have code that triggers notices or warnings only in certain PHP versions. As I said, the overall problem is very easy to understand; use some time to fix it and not just mask it. – Álvaro González Jun 28 '17 at 17:11
-
digyourbrain.org/images/logincode.PNG Please copy and paste this url or click to see my code and guide me since for long i have been struggling with this issue – Jun 29 '17 at 03:59
-
Don't you get `Notice: A session had already been started - ignoring session_start()` when you try to start session twice? – Álvaro González Jun 29 '17 at 08:46
1 Answers
-1
Without more detail about your specific issue, all I can tell you is that headers must be set in PHP before anything else is output. You must be sending some form of output before you are attempting to set the header.

Joshua Jones
- 1,364
- 1
- 9
- 15
-
http://digyourbrain.org/images/logincode.PNG Please copy and paste this url to see my code and guide me since for long i have been struggling with this issue. – Jun 29 '17 at 03:57
-
First of all, you are potentially calling `session_start()` twice, in the event that a user is found. That would not cause an error, but you should not be doing it. The error is potentially being raised due to output in config.php, or you are modifying the header in dashboard.php. – Joshua Jones Jun 29 '17 at 05:12
-
Thanks for responding. I will correct the code and this time i wont change php version but will try to improve the code itself in order to get rid off this issue. – Jun 29 '17 at 09:31