Sunday , 20 April 2014
Home » PHP Programming » Common Issues/Bugs » Solved – Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent
Solved – Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent

Solved – Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent

Hello Friends, This is the most common error, you will face when you will start working with sessions in PHP. I got below error. "Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent" and i got success to solve this. So i would like to share this with all of you.

There are many ways,this error originates. Below are some cases which may solve above error for you.

Look at below links for solutions.

Solution 1: Write ob_start() before session_start() statement. As ob_start() turn on output buffering means no output sent to script and it stores the output in internal buffer.
Solution 2: If solution one does not work for you than please make sure that nothing gets sent to the browser before session_start() statement. This happens in case there is a white space or some charactors before session_start() or even before <?php tag. If this is the case, please remove spaces or charactors.It will sovle the "Cannot send session cache limiter" problem.
Solution 3: If both solutions does not make any difference and still you have the same problem than try to set the encoding from UTF-8. UTF-8 encoding add some characters before <?php tag which is the same case as solution 2 and you have remove those charactors. But as those charactors automatically output in page, you can solve this by using UTF-8 encoding WITHOUT BOM (Byte Order Mark). "Don't save your UTF-8 files with BOM as it creates issues".

To know more about programming,MYSQL database,php info,php editor,programming php,Open-source,php help and php script , subscribe to our feed by entering email address below. You will get updates via email about every tutorial posted on this site . It will not take more than a sec.

Enter your email address:
 
Feel free to ask any question. Just leave your comment below and we will answer your comment with in 24 hours.

About Rakshit Patel

I am PHP Freelancer, Rakshit Patel AKA WordPress Freelancer working as PHP Programmer India. I am here to share all my developing knowledge, quick coding techniques, quick solutions to save your time and help you guys for any issue or bug fixing. If you have any PHP, WordPress, Magento related work, please contact me. I am interested for the work.

40 comments

  1. thank you very much… very useful

  2. thank you very much… very useful

  3. thanks buddy, great done! :)

  4. None of the above helped me :( but thank you for sharing!

  5. Hi RakshitI would really appreciate some help….I’m having exactlty this problem and wondered if you could take a look at it for me. Any advice would be really appreciated. Its a “caspio” embeded datapage using wordpress. Their support says they cannot find a bug. They have tested exactly the same installation setup on their own server and it works fine without the error.I have hit a complete brick wall in terms of sorting the problem and could really use some help.Thanks Luke

  6. ya your solution is working

    thank you very much

  7. Hi
    I still get this error
    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent

    I have tried all the suggested things and it still doesn’t fix the problem.

    I have this at the start of the page
    <?php
    ob_start();
    session_start();

    please help if anyone has some other ideas, i'm going mad trying to solve this

    thanks
    steve

  8. Help me to solve this error.
    No one Solution is work for me … :(
    Please help me

  9. help me this much of warning Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent.

  10. hai this is venki am got solution this problem,

    don’t put free face before
    to create begineing the page

  11. hai this is venki ,
    u put the beginig

  12. You saved my life! I hope I will be able to write an article as helpful as your in the future!

  13. Prabudha Kushagra

    thanks buddy…. it helped me a lot

  14. Thankyou. But Warning Messages are also printed to the file. What I how can I remove them.

  15. good one it help me to solve my problem

  16. thanks man

  17. mate you are like my new best friend
    this problems has been p*****g me off for soo long and you just solved it for me
    cheerse pal

  18. Hi! thanks for this article. It helped a lot (My problem is solved with solution #3).

    Is there an explanation to why is this happening?

  19. Thanks for your solution. Its works for me.

  20. Hello, i am having this same issue, and I am ready to pull my hair out trying to figure it out. None of the solutions worked for me. My pages are encoded with utf-8 without the BOM, yet I am still getting this error.

    <?php
    session_start();

    //Include database connection details
    require_once('includes/config.php');
    require_once('includes/constant.php');
    //Array to store validation errors
    $errmsg_arr = array();

    //Validation error flag
    $errflag = false;

    If you cvould please give me some tips as to why this is till hapening, I would be forever grateful. Thanks in advance.

  21. Please make sure that there is no space before start of page().

  22. there is no white space at the beginning of my page, the session_start; is on line 2 of the php file with no white space before it. There are no HTML tags before it either. I should also say that this works on other pages on the site as all the pages are coded the same way. It just does not make nay sense to me. Any ideas? Thanks

  23. ob_start();
    session_start();
    ini_set (‘session.use_cookies’, 1000);
    $_SESSION['session_name'] = “superadmin”;
    $_SESSION['userid'] =”0″;

    but still that error

  24. Thanks bud.. Worked like a charm for me.. :-)

  25. yep..very useful.thanks.I am using osclass.org soft and get this problem.solution 2 solved my problem.

  26. thanks so much, silly error

  27. The space before <?php caused the problem… thanx man

  28. thanx alot…the first solution worked like a charm….

  29. thanks for the post its very helpful. It solved my error.

  30. Thanks dude ! it really works after edit from Ultra Edit software.

  31. Just donwload notepad++ and select
    encoding -> encode with utf-8 without BOM and save the php file.

    it works

  32. thank you so much for the explanation.

    option 2 worked for me very well.
    i placed the session tag above the .

    and it worked ;)

  33. Thanks you!!! its helps me..

  34. Hello, I have another (4th) way, to solve the problem wich should be mentioned in the article above or for anybody who reads this…

    I found out, that having the php code in an windows formated textfile (with .php ending) running on a linux server causes this problem with this “Warning: … Cannot send session cache limiter – headers already sent” message as well. As soon as I converted this file to a unix styled textfile the warning messages disapeared!

    You can’t believe how happy I am, after years and years of showing this error?!!

    Thank god, for having a solution now!

    All the best for you!

    Greetz, Benjamin

  35. thank you it is very helpful for me.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>