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() [function.session-start]: Cannot send session cache limiter

Discussion in 'PHP' started by chillywilly, Sep 13, 2007.

  1. #1
    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent
    Code (markup):
    I transfered my website from a shared hosting account to a dedicated box. In my download area I'm now getting this error.
    SEMrush
     
    chillywilly, Sep 13, 2007 IP
    SEMrush
  2. hamidof

    hamidof Peon

    Messages:
    619
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Up on top of your script, before includes etc. put this:
    
    ob_start("ob_gzhandler");
    
    PHP:
    If it worked, then your previous hosting package had output buffering enabled in PHP.ini
     
    hamidof, Sep 13, 2007 IP
  3. chillywilly

    chillywilly Active Member

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #3
    I can't seem to get that work using your code. Thanks for your quick reply though.
     
    chillywilly, Sep 13, 2007 IP
  4. hamidof

    hamidof Peon

    Messages:
    619
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #4
    hamidof, Sep 13, 2007 IP
  5. chillywilly

    chillywilly Active Member

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Thank you hamidof that worked perfectly!

    Was banging my head against the desk for awhile on that one. A+ fix.
     
    chillywilly, Sep 13, 2007 IP
  6. stisoon

    stisoon Peon

    Messages:
    73
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    stumbled on this on google. thanks. simple explanation always helps.
     
    stisoon, Jan 18, 2008 IP
  7. LimeBlast

    LimeBlast Peon

    Messages:
    81
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #7

    Put you session start at the begining of your code (like line 1 or so)!
     
    LimeBlast, Mar 23, 2008 IP
  8. TheAdMan

    TheAdMan Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thanks Hamidof..
    I had white spaces... :

    Thanks for your advice
     
    TheAdMan, Dec 15, 2009 IP
  9. Frank Hayward

    Frank Hayward Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    try putting

    <?php
    require_once('yourpage.php');
    ?>

    before the <head> </head> code
     
    Frank Hayward, Jul 14, 2010 IP
  10. bokivaol

    bokivaol Greenhorn

    Messages:
    66
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #10
    Thank you a lot, that solved my problem!
     
    bokivaol, Aug 14, 2010 IP
  11. martybabes

    martybabes Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    I had this problem as well. When I read about the characters appearing before the session_start() I remembered the problem I replies had downloading pages to test server. The warning did not appear on the test server because - I have E_NOTICES 'off' on my test server, but they are 'on' on the www server.
    Using file manager on www server, I found some pages have a dash tacked on at the very start so I get...
    sample.php
    line1: -<?php
    As you can see, the dash will be output, hence the warning:)
     
    martybabes, Aug 22, 2010 IP
  12. RaPeRbOy

    RaPeRbOy Active Member

    Messages:
    425
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    90
    #12
    Make sure your encoding file type is UTF-8 without BOM.
     
    RaPeRbOy, Apr 7, 2011 IP
  13. healingoasis

    healingoasis Peon

    Messages:
    153
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #13
    I am getting the same error message:

    Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/alsabah/public_html/4dvd.com/include/session.php:1) in /home/alsabah/public_html/4dvd.com/include/session.php on line 25

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/alsabah/public_html/4dvd.com/include/session.php:1) in /home/alsabah/public_html/4dvd.com/include/session.php on line 25

    I have looked for the issue and have not found it. Here is the page code. If anyone could help I would really appreciate it.

    <?
    include("database.php");
    include("form.php");

    class Session
    {
    var $username; //Username given on sign-up
    var $userid; //Random value generated on current login
    var $userlevel; //The level to which the user pertains
    var $time; //Time user was last active (page loaded)
    var $logged_in; //True if user is logged in, false otherwise
    var $userinfo = array(); //The array holding all user info
    var $url; //The page url current being viewed
    var $referrer; //Last recorded site page viewed
    var $ip; //Remote IP address

    function Session(){
    $this->ip = $_SERVER["REMOTE_ADDR"];
    $this->time = time();
    $this->startSession();
    }

    function startSession(){
    global $database;
    session_start();


    Regards,
    H.
     
    healingoasis, Jun 15, 2011 IP
  14. mohammad-v

    mohammad-v Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    tnx , that solved my problem .
     
    mohammad-v, Jul 7, 2011 IP
  15. dsoft

    dsoft Greenhorn

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #15
    UltraEdit Text Editor is a very good tool that gives you the option to save files encoded with BOM or without BOM. Check it out.
    I had the same problem as you, but after reading some forums i found out the solution, and used Ultra Edit to save my files without BOM.
     
    dsoft, Jul 8, 2011 IP
  16. AdsMakeSense

    AdsMakeSense Active Member Premium Member

    Messages:
    389
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    70
    #16
    Make sure nothing is echoed or outputed before you start your session.
     
    AdsMakeSense, Jul 9, 2011 IP
  17. US Vice

    US Vice Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    error_reporting(0);
     
    US Vice, Jul 9, 2011 IP
  18. ApisMatt

    ApisMatt Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #18
    I was having the same issue as above, and found out that:

    <?php //anything ?>
    <?php //anything ?>

    is actually creating white space. And this doesn't:

    <?php
    //anything
    //anything
    ?>
     
    ApisMatt, Mar 9, 2012 IP
  19. 7sk

    7sk Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #19
    if you still have these errors then give me your website like and let me resolve it for you, as i had such errors and now my all websites are error free.

    the main problem was malware script which found in my index.php file.

    when I removed that script now it is fine enough.

    in your case when you transfered your website to other hosting, the other hosting may be infected already and you website get infected as well.
     
    7sk, Mar 13, 2012 IP
  20. kulwindergrewal

    kulwindergrewal Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #20
    i have still this prob .. do everyting .. :(

    1) Remove white spaces
    2) session start on 1st line after <?php
    3) encoding utf8 without bom
    4)ob_gzhandler and ob_start()

    plz plz somebody help me out..

    warning: session_start() [function.session-start]: open(/var/chroot/home/content/76/8154676/tmp/sess_6e99jvf1mthr821cn8j5stti44, O_RDWR) failed: No such file or directory (2) in /home/content/76/8154676/html/admin/index_action.php on line 2

    warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/76/8154676/html/admin/index_action.php:2) in /home/content/76/8154676/html/admin/index_action.php on line 2
     
    kulwindergrewal, May 12, 2012 IP