0
<?php
if(session_id() == '' || !isset($_SESSION))
session_start();
?>

i have this line of code in all my pages... and it is located at the very top of my script.. but unfortunately im getting an error on one of my script but the other pages didn't get error... i tried to search it but they said that it is needed to be at the top of script before HTML.. just what i did... but i dont have any idea why im getting error on one of my pages.. i found this error when i start to upload it to my cpanel server.. but on my local server its totally working..
this is the warning message that i got.. and when i tried to remove this on one of my script which gives me the error message my page did not functioning well

Warning: session_start(): Cannot send session cache limiter - headers already sent

Lion Smith
  • 647
  • 3
  • 16
  • 48

2 Answers2

0

The session_start() function needs to be the first one

<?php
session_start();
if(session_id() == '' || !isset($_SESSION))
?>
Daniel Paiva
  • 121
  • 2
  • 10
  • 2
    *"The session_start() function needs to be the first one"* Not really. OP is checking the session isn't already started before starting it. Having an `if()` condition before `session_start()` is fine as long as no headers are sent before it. – ʰᵈˑ Apr 27 '17 at 10:57
  • i tried it but nothing happens still i got the error message... on my server... – Lion Smith Apr 27 '17 at 11:12
0

Posting as an asnwer as per the comment made by OP

This occurs if you have output before session_start() is called. The most typical culprit is a space (or any character) before the <?php tag (be aware of zero-width space characters also).

Community
  • 1
  • 1
ʰᵈˑ
  • 11,279
  • 3
  • 26
  • 49