Peter BoydHow to Fix: Warning: session_start() [function.session-start]: Cannot send session cache limiter

We recently came across this pesky problem and found these two articles very helpful.

Don’t save your UTF-8 files with BOM as it creates issues.

=================

http://juicystudio.com/article/utf-byte-order-mark.php

“Headers must be written before any data is sent to the client. Unicode files may include a Byte-Order Mark (BOM) to help distinguish the big endian and little endian byte order. Unfortunately, the BOM isn’t understood by PHP. Upon encountering the BOM, PHP assumes that it is dealing with data, by which time it’s too late to modify headers. Solution? Save the file in UTF-8 encoding without a BOM.”

and

http://69.147.83.196/bug.php?id=44563&edit=2

“If file A or file B has UTF-8 encoding then you will get the error:

Warning: session_start() [function.session-start]: Cannot send session
cache limiter – headers already sent (output started at index.php:1) in
session.php on line 3

Using UTF-8 encoding WITHOUT BOM (Byte Order Mark) seems to fix the
problem.”

=================

If file A or file B has UTF-8 encoding then you will get the error:

Warning: session_start() [function.session-start]: Cannot send session
cache limiter - headers already sent (output started at index.php:1) in
session.php on line 3

Using UTF-8 encoding WITHOUT BOM (Byte Order Mark) seems to fix the
problem.


Comments? Let us know your thoughts.

53 Responses to How to Fix: Warning: session_start() [function.session-start]: Cannot send session cache limiter

  1. viderbit
    6:21 am on August 4th, 2009

    Omg thanks bro, i can’t believe that BOM can make browser to thing that receive header information instead BOM signature…

  2. David@iconera
    6:09 pm on January 10th, 2012

    my site hosted live and i used the editor in cpanel to make one small change. nexst thing the error came up. thankfully we have google and people who post solutions. TIP: if you use the cpanel editor, use the code editor it works for php.
    Regard

    David
    Icon Era

  3. Tinu
    4:22 am on August 11th, 2010

    please ensure that these is nothing before session_start() command. Even a white space before the session_start() command will generate this warning message

    Wrog:

    Correct:

  4. Alok
    2:11 am on March 7th, 2011

    Dear, u r right a white space created problem in my code and i rectified it, thank you very much.

  5. Bojan
    8:48 am on January 13th, 2011

    Than you very much =) I almost give up on fixing this error, but thanks to you the error is now gone 🙂

  6. Terminal
    2:57 pm on March 8th, 2011

    Thanks bro. It was too painfully for me. But now it works fine just after eliminating the white space before php tag.

    Many many thanks

  7. Golyoka
    5:07 pm on March 28th, 2011

    Many many thanks, i s*ck with these error about 2 hours.

  8. Canguingo
    5:20 pm on March 29th, 2011

    peteboyd i love you so much!!! problem solved, not only the file cousing the warning but all files should not be saved in UTF-8… 😉

    many many thanx!

  9. emilakia
    1:58 pm on August 11th, 2011

    thanks a lot!!!!!!!:):)

  10. Zobi_89
    9:14 am on September 11th, 2011

    can anybody fix it plz..i m fucked up but can fixed it ..get same erroe of session cant start..

    login_check

    0) {
    $errorMessage= “logged on “;
    }
    else {
    $errorMessage= “Invalid Logon”;
    }
    if (rows > 0) {
    session_start();
    $_SESSION[‘login’] = “1”;
    header (“Location: verify.php”);
    }
    else {
    session_start();
    $_SESSION[‘login’] = ”;
    }
    ?>

  11. liladhar
    5:24 am on September 16th, 2011

    Warning: session_start() [function.session-start]: Cannot send session cookie – headers already sent by (output started at D:Sitessingle57liladharmangewebrootsbseditprofile.php:1) in D:Sitessingle57liladharmangewebrootsbseditprofile.php on line 2
    kindly help in above

  12. Solicitoraver
    11:50 am on June 6th, 2012

    Thanks….thanks…..thanks so much….I never knew about this BOM(Byte Order Mark) until now….my problem just got solved on the fly…..thanks so much for this tutorial…..citor(Nigeria)

  13. Mmehdibalouchi
    2:00 pm on July 30th, 2012
  14. nitesh
    3:28 am on August 22nd, 2012

    i am using dremviewer and Netbeans as editior how can i save file without BOM (Byte Order Mark ) in UTF -8 charset

  15. jasu
    2:29 am on November 2nd, 2012

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home/content/e/z/e/ezesite/html/clients/deepakchandran/satlineglobal.com/edit_profile.php:7) in /home/content/e/z/e/ezesite/html/clients/deepakchandran/satlineglobal.com/edit_profile.php on line310

  16. M.
    2:05 am on January 10th, 2013

    You can also save the file as ANSI using the good-old Notepad. Open file with Notepad, File > Save-As > (bottom right) Encoding ANSI.

  17. Thiago Bluhm
    12:25 pm on February 19th, 2013

    Tnk u so much!

  18. Kimaru Sensei
    9:00 pm on March 24th, 2013

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at C:\xampp\htdocs\b\index.php:9) in C:\xampp\htdocs\b\index.php on line 10
    not login

    –> HERES MY CODE

    Untitled Document

    –> help please

  19. Peter Boyd
    9:16 am on March 25th, 2013

    Hello Kimaru, you need make sure resave your file and make sure there are no whitespace characters at the beginning.

  20. anandavel
    12:08 am on April 25th, 2013

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home/pragmat2/public_html/MEProject/main.php:13) in /home/pragmat2/public_html/MEProject/main.php on line 13
    Congra

  21. anandavel
    12:09 am on April 25th, 2013

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home/pragmat2/public_html/MEProject/main.php:13) in /home/pragmat2/public_html/MEProject/main.php on line 13
    pls help me and advance thks

  22. Nouman Rifat
    1:34 am on April 28th, 2013

    i was also having same problem in joomla. There are 2 causes of this
    1) Check the configuration file and see if there is a blank space before
    2) Save your configuration file in ANSI and upload to server again

    I resolved by issue with the 2nd case
    Thanks to someone who helped me on joomla’s forum 🙂

  23. sathiya
    3:01 am on May 1st, 2013

    i get this warning msg ……
    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at D:\PROJECT DATA\xampp\htdocs\css\admin.php:16) in D:\PROJECT DATA\xampp\htdocs\css\admin.php on line 124
    help me….

  24. Peter Boyd
    7:40 am on May 3rd, 2013

    Clear out any whitespace at the beginning of the file or end of the file. Also, try cutting/pasting into notepad and resaving the file.

  25. anandavel
    6:03 am on May 16th, 2013

    hai i also getting same error

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home/pragmat2/public_html/MEProject/main.php:4) in /home/pragmat2/public_html/MEProject/main.php
    any body could pls help me

  26. Robert Watcher
    7:56 am on June 13th, 2013

    Glad I came across this so I could give it a try.

    My scenario is that I am not worried about “white space” because I am using “ob_start()” to buffer the output. I have several scripts that I wrote based on the php same code.

    When I moved my accounts to a new VPS server yesterday – all of a sudden the warning showed up on one of the websites. I couldn’t figure it out so squelched the output showing by putting * in front of session_start(); (*session_start();)

    I didn’t like doing that and kept searching – only to find this solution and have it work. For some reason the warning was not happening on the other websites that used similar coding with object_start(). They must have been encoded without the BOM.

  27. nidhi
    11:47 am on July 3rd, 2013

    Awesome fix!!! 😀 love it.

  28. Rakesh
    7:27 am on July 5th, 2013

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

  29. Nikki
    12:29 pm on July 16th, 2013

    Thank you! This fixed my problem!

  30. sathish
    12:23 am on July 31st, 2013

    Thank you . error fix 🙂 .

    I have save the file formate “UTF-8 encoding without a BOM”.

    This options open notepad++ top menu “Encoding”

  31. Michael
    9:35 am on August 2nd, 2013

    Thanks. That was it!

  32. adam
    1:13 am on August 3rd, 2013

    wow its work…, just by removing a white space befor <?PHP tag

  33. Yogesh
    10:45 am on September 26th, 2013

    Warning: session_start() [function.session-start]: Cannot send session cookie – headers already sent by (output started at C:\Inetpub\vhosts\gwaliorsearch.com\httpdocs\index.php:8) in C:\Inetpub\vhosts\gwaliorsearch.com\httpdocs\index.php on line 78

  34. Chris
    8:08 pm on January 6th, 2014

    Thanks! I had some Google Analytics Code comment out above my php, and when I swapped them around to have the php on the top it fixed the error!

  35. Varsha Chaudhari
    2:21 am on February 24th, 2014

    I got this warning message.and Can Please told me where to write session code or give me solution of it.
    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home/astutvsy/public_html/index.php:2) in /home/astutvsy/public_html/includes/header-index.php on line 2

  36. Faride
    7:12 am on May 28th, 2014

    This was exactly what was causing me trouble.
    Thank you sooooooo much for your accurate solution.

  37. Jimmy Ekisa
    6:47 am on June 28th, 2014

    I am getting the following error:
    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at C:\xampp\htdocs\Crime\login.php:6) in C:\xampp\htdocs\Crime\login.php on line 7

    Warning: Cannot modify header information – headers already sent by (output started at C:\xampp\htdocs\Crime\login.php:6) in C:\xampp\htdocs\Crime\login.php on line 26

    I have tried all above suggestions but not working. Below is my login.php code

    Untitled Document

    <?php
    session_start();
    $UserName=$_POST['username'];
    $Password=$_POST['password'];
    $UserType=$_POST['cmbUser'];
    if ($UserType=="Admin")
    {
    $con = mysql_connect("localhost","root");
    mysql_select_db("cms", $con);
    $sql = "select * from Admin_Tbl where Admin_Name='".$UserName."' and Admin_Password='".$Password."'";
    $result = mysql_query($sql,$con);
    $records = mysql_num_rows($result);
    $row = mysql_fetch_array($result);
    if ($records==0)
    {
    echo $records;
    echo 'alert(“Wrong UserName or Password”);window.location=\’index.php\’;’;
    }
    else
    {
    header(“location:Admin\index.php”);
    }
    mysql_close($con);
    }
    else if($UserType==”Police”)
    {
    $con = mysql_connect(“localhost”,”root”);
    mysql_select_db(“cms”, $con);
    $sql = “select * from policestation_tbl
    where UserName='”.$UserName.”‘ and Password='”.$Password.”‘”;
    $result = mysql_query($sql,$con);
    $records = mysql_num_rows($result);
    $row = mysql_fetch_array($result);
    if ($records==0)
    {
    echo $records;
    echo ‘alert(“Wrong UserName or Password”);window.location=\’index.php\’;’;
    }
    else
    {
    $_SESSION[‘ID’]=$row[‘Station_Id’];
    $_SESSION[‘Name’]=$row[‘Station_Name’];
    header(“location:PoliceStation\index.php”);
    }
    mysql_close($con);
    }
    else
    {
    $con = mysql_connect(“localhost”,”root”);
    mysql_select_db(“cms”, $con);
    $sql = “select * from User_Tbl where UserName='”.$UserName.”‘ and Password='”.$Password.”‘”;
    $result = mysql_query($sql,$con);
    $records = mysql_num_rows($result);
    $row = mysql_fetch_array($result);
    if ($records==0)
    {
    echo $records;
    echo ‘alert(“Wrong UserName or Password”);window.location=\’index.php\’;’;
    }
    else
    {
    $_SESSION[‘ID’]=$row[‘User_Id’];
    $_SESSION[‘Name’]=$row[‘Name’];
    header(“location:RegUser\index.php”);
    }
    mysql_close($con);
    }
    ?>

  38. saeeded
    4:38 pm on August 11th, 2014

    Thanks for helpful replies …

  39. asim
    6:21 pm on August 18th, 2014

    i have same problem i am not coder and not know php filese please tell me which files need to edid from this error and how i can edit

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home/adeel33/public_html/New Folder/admin/index.php:1) in /home/adeel33/public_html/New Folder/admin/library.php on line 16

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home/adeel33/public_html/New Folder/admin/index.php:1) in /home/adeel33/public_html/New Folder/admin/library.php on line 16
    
    Warning: Cannot modify header information – headers already sent by (output started at /home/adeel33/public_html/New Folder/admin/index.php:1) in /home/adeel33/public_html/New Folder/admin/includes/class_admin.php on line 60

    Warning: Cannot modify header information – headers already sent by (output started at /home/adeel33/public_html/New Folder/admin/index.php:1) in /home/adeel33/public_html/New Folder/admin/includes/class_admin.php on line 61

    Warning: Cannot modify header information – headers already sent by (output started at /home/adeel33/public_html/New Folder/admin/index.php:1) in /home/adeel33/public_html/New Folder/admin/includes/class_admin.php on line 62

    Warning: Cannot modify header information – headers already sent by (output started at /home/adeel33/public_html/New Folder/admin/index.php:1) in /home/adeel33/public_html/New Folder/admin/sources/login.php on line 64

  40. Allison
    11:49 am on August 19th, 2014

    @asim Strip out white space. Also, try running it through notepad first.

  41. Bonita
    2:29 am on October 1st, 2014

    urk! What a pain! My website didn’t have any issues until I added a login code, and then I got this error. But I’ve used the same login code across other sites without experiencing difficulties.

    Fingers crossed, let’s hope I get this sorted out!

  42. Bengal Blooms
    2:23 am on January 13th, 2015

    I am getting the following error when i am opening my website:-

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home3/jatinjos/public_html/bengalblooms.com/index.php:10) in /home3/jatinjos/public_html/bengalblooms.com/vqmod/vqcache/vq2-system_startup.php on line 30
    Warning: Cannot modify header information – headers already sent by (output started at /home3/jatinjos/public_html/bengalblooms.com/index.php:10) in /home3/jatinjos/public_html/bengalblooms.com/index.php on line 188

    Anybody could help me please.
    Thanks

  43. nai
    3:25 am on March 14th, 2015

    thanks, Your right.!! now I already fixed my error.. 😀 🙂

  44. Narendra
    6:03 am on May 18th, 2015

    Below are the error which i am getting.on local pc its working but on server not working please help me

    Warning: session_start(): Cannot send session cookie – headers already sent by (output started at /home3/hybreed/public_html/store/php/orderDetails.php:3) in /home3/hybreed/public_html/store/php/orderDetails.php on line 4

    Warning: session_start(): Cannot send session cache limiter – headers already sent (output started at /home3/hybreed/public_html/store/php/orderDetails.php:3) in /home3/hybreed/public_html/store/php/orderDetails.php on line 4

    Warning: Cannot modify header information – headers already sent by (output started at /home3/hybreed/public_html/store/php/orderDetails.php:3) in /home3/hybreed/public_html/store/php/orderDetails.php on line 160

  45. Peter Boyd
    1:50 pm on May 18th, 2015

    I would recommend trying to get rid of any white space at the beginning of your file or possibly end of the file. Check around the cookie line. Perhaps even cut/paste from lines 1 – 4 into notepad, remove all spaces and paste back into the main php file.

  46. Nick
    8:47 am on May 31st, 2015

    Thank You very much..it helped – the white space thing didnt but saving the file as Utf – without BOM on note++ did the trick..Thank you…this only comes up on old

  47. zakaria
    11:33 pm on June 4th, 2015

    please help me

    Warning: session_start() [function.session-start]: open(\tmp/sess_10e42cd5b142debbe4a0fb855dc55467, O_RDWR) failed: No such file or directory (2) in /home/sman10smg123/public_html/elearning/www/index.php on line 13

    Warning: session_start() [function.session-start]: Cannot send session cookie – headers already sent by (output started at /home/sman10smg123/public_html/elearning/www/index.php:13) in /home/sman10smg123/public_html/elearning/www/index.php on line 13

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home/sman10smg123/public_html/elearning/www/index.php:13) in /home/sman10smg123/public_html/elearning/www/index.php on line 13

    Warning: session_regenerate_id() [function.session-regenerate-id]: Cannot regenerate session id – headers already sent in /home/sman10smg123/public_html/elearning/www/index.php on line 15

    Warning: Cannot modify header information – headers already sent by (output started at /home/sman10smg123/public_html/elearning/www/index.php:13) in /home/sman10smg123/public_html/elearning/www/index.php on line 16

  48. nikit
    7:48 am on June 24th, 2015

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at E:\xampp\htdocs\projects\crm\crm\vendorpopup.php:1) in E:\xampp\htdocs\projects\crm\crm\vendorpopup.php on line 1

  49. jeebandeep mahapatra
    5:46 am on April 6th, 2016

    Thank you so much for solving my issue.

  50. Alex Klossner
    3:47 am on June 12th, 2016

    Hello,
    I have the same problem. I have try to fix it with all your suggestion from above. My website works on other fine on other hosting. From the beginning the encoding was UTF-8 without BOM so I tri to change in ANSI (without results),
    no white space , I already fix that.
    Warning: session_start() [FUNCTION.SESSION-START]: Cannot send session cookie – headers already sent by (output started at /home/logisti1/public_html/index.php:1) in /home/logisti1/public_html/init.php on line 3

    Warning: session_start() [FUNCTION.SESSION-START]: Cannot send session cache limiter – headers already sent (output started at /home/logisti1/public_html/index.php:1) in /home/logisti1/public_html/init.php on line 3

    Thank you in advance

  51. Adeel Ansar
    8:46 am on October 21st, 2016

    Start Session just after staring body.

  52. Adeel Ansar
    8:46 am on October 21st, 2016

    I mean html body tag.

  53. fantom214
    5:18 pm on February 7th, 2017

    God Bless U. Worked for me! Thanks.

Leave a Reply

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

*

 



Subscribe to our Newsletter




Free Website Analysis & Consultation. Contact Us Today