1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Warning: Session Start (Error), How to remove it?

Discussion in 'PHP' started by 7sk, Mar 13, 2012.

  1. #1
    I am facing this ugly error on header of my website, how I can remove it.



    Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/eitlabs1/public_html/salmanoreen.com/index.php:1) in /home/eitlabs1/public_html/salmanoreen.com/libraries/joomla/session/session.php on line 423

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/eitlabs1/public_html/salmanoreen.com/index.php:1) in /home/eitlabs1/public_html/salmanoreen.com/libraries/joomla/session/session.php on line 423

    Warning: Cannot modify header information - headers already sent by (output started at /home/eitlabs1/public_html/salmanoreen.com/index.php:1) in
     
    7sk, Mar 13, 2012 IP
  2. dujmovicv

    dujmovicv Member

    Messages:
    62
    Likes Received:
    2
    Best Answers:
    4
    Trophy Points:
    48
    #2
    The error means that somewhere in the code, something was printed to the browser before Joomla (according to the file path) had finished preparing the page. This is most often caused by custom or modified code contributed from sources outside Joomla, so inspect your uniquely added code (including themes) first... Check if you have added any print or echo command BEFORE the header is called :
    
    echo "blah blah";
    header('Location: http://www.example.com/');
    
    PHP:
    To solve :
    
    function JavaScriptRedirect($redirect_url) {
    ?>
    <script type="text/javascript">
      window.location = "<?=$redirect_url;?>"
    </script>
    <?
    }
    echo "blah blah";
    JavaScriptRedirect("http://www.example.com/");
    
    PHP:
     
    dujmovicv, Mar 13, 2012 IP
  3. SoftCloud

    SoftCloud Well-Known Member

    Messages:
    1,060
    Likes Received:
    28
    Best Answers:
    2
    Trophy Points:
    120
    #3
    I'd just stick this at the very top of my file - always works.
    ob_start();
    Code (markup):
    Example:
    <?php
    ob_start();
    ?>
    PHP:
     
    SoftCloud, Mar 13, 2012 IP
  4. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #4
    I disagree with ob_start();. This is basically a bandaid for poor coding. You fundamentally shouldn't be outputting anything before the headers and cookies are set. Find what is outputting to the browser and correct it.
     
    jestep, Mar 13, 2012 IP
  5. 7sk

    7sk Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #5
    I found the above mentioned problem. it was problem in index.php there was a malware script before php code starts, when I removed that script my problem get resolved. I had same problem with all of my websites which are hosted on same server, it means my hosting get some hack attack and someone put some script injection to all of my websites. and when such script get removed websites get errors free.
     
    7sk, Mar 13, 2012 IP
  6. 7sk

    7sk Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #6
    but I am unable to login in backend. here I am sharing one of my admin login page, kindly let me know from where I can manage it. I am facing such errors.

    error_reporting(0)
    Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/eitlabs1/public_html/salmanoreen.com/administrator/index.php:2) in /home/eitlabs1/public_html/salmanoreen.com/libraries/joomla/session/session.php on line 423

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/eitlabs1/public_html/salmanoreen.com/administrator/index.php:2) in /home/eitlabs1/public_html/salmanoreen.com/libraries/joomla/session/session.php on line 423

    Warning: Cannot modify header information - headers already sent by (output started at /home/eitlabs1/public_html/salmanoreen.com/administrator/index.php:2) in /home/eitlabs1/public_html/salmanoreen.com/libraries/joomla/session/session.php on line 426
     
    7sk, Mar 13, 2012 IP
  7. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #7
    Post the top 10 or so lines of index.php
     
    jestep, Mar 13, 2012 IP
  8. SoftCloud

    SoftCloud Well-Known Member

    Messages:
    1,060
    Likes Received:
    28
    Best Answers:
    2
    Trophy Points:
    120
    #8
    I agree that it isn't the best thing - but as a quick fix it's good enough for me. :) (Am known for my messy coding - but my theory is, as lo0ng as it works, that's all that matters) :p
     
    SoftCloud, Mar 13, 2012 IP
  9. lonelygrit

    lonelygrit Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Yes show your code
     
    lonelygrit, Mar 14, 2012 IP