Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    error:...cannot send session cache limiter... headers already sent by php...

    error:...cannot send session cache limiter...
    headers already sent by php....can any one give me the solution?..........when ever login with username & password...the session is not stored in the first time....but the next time login the session is stored with the username....what is the prblm?.....i m sending code also......

    <?ob_start();
    session_start();?>
    <?php
    $_SESSION['susername']=$_POST["username"];
    if($_SESSION['susername']=="")
    $ssusername= $_SESSION['profileusername'];
    else
    $ssusername= $_SESSION['susername'];
    Header("Location: ./profile.php");
    if($ssusername=="")
    require "serverbusy.html";
    //session_register("ssusername");
    ?>
    please give me the reply.........
    i m waiting for that............

  • #2
    Regular Coder
    Join Date
    Mar 2006
    Posts
    238
    Thanks
    3
    Thanked 37 Times in 37 Posts
    I think you have a space before "<?ob_start();". In this case the server has already started output of the HTTP document. Which means the HTTP headers are already sent.

    Please check that there in no output before "<?ob_start();" in your script. Absolutely nothing - even spaces. If the output has started, it could be a little bit late to turn on buffering ... Headers have been sent already.

  • #3
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    there is no spaces before "<?ob_start();". .....the same code in local machines worked successfully.....i uploaded code into internet.......it will give the error....what is the reason....can u give me any other option......plz give me the reply........

  • #4
    Regular Coder
    Join Date
    Mar 2006
    Posts
    238
    Thanks
    3
    Thanked 37 Times in 37 Posts
    This code
    PHP Code:
    <?ob_start();
    session_start();?>
    <?php
    $_SESSION
    ['susername']=$_POST["username"];
    if(
    $_SESSION['susername']=="")
    $ssusername$_SESSION['profileusername'];
    else
    $ssusername$_SESSION['susername'];
    Header("Location: ./profile.php");
    if(
    $ssusername=="")
    require 
    "serverbusy.html";
    //session_register("ssusername");
    ?>
    works for me without any problems andd does not produce any errors. I tried it both under Windows and under Linux.

    Have you posted all the errors you are getting from the script ? Only "can not send session cache limiter. Headers already sent" ? Maybe some other error has been shown before this ? In this case that error would be the the output about which the server complained ... I am sorry for asking questions, but without this information it is really difficult to help ...

    This "Headers already sent" error could mean only 1 thing - some output has started before you used a function sending HTTP headers (in your case session_start()).

    The line "<?ob_start();" is really the first line in the script file with nothing before it ?

    Off-topic: I would use "<?php ob_start();" instead of "<?ob_start();". Using short tags ("<?" instead of "<?php") is considered bad programming practice. If once you move your code to a server with short tags off, you would get all your PHP code in the browser as plain text for anyone to view. Also I do not see why you could possibly need ob_start() in this small script at all ...
    Last edited by SKDevelopment; 09-15-2009 at 10:43 AM.

  • #5
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    sir,
    in my server the code is working perfectly.....but i m using bravenet hosting server....it will give the error....i m sending error message:
    Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /misc/16/000/211/946/9/user/web/dianimations.com/login.php:8) in /misc/16/000/211/946/9/user/web/dianimations.com/index1.php on line 2

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /misc/16/000/211/946/9/user/web/dianimations.com/login.php:8) in /misc/16/000/211/946/9/user/web/dianimations.com/index1.php on line 2

    Warning: Cannot modify header information - headers already sent by (output started at /misc/16/000/211/946/9/user/web/dianimations.com/login.php:8) in /misc/16/000/211/946/9/user/web/dianimations.com/index1.php on line 75

    when ever login with username the session is empty....if u login second time it will take session as username.....i want: when ever login with username the session is stored with ssusername.....
    if u want check my website:www.dianimations.com
    username:srihari3d
    password:devineni

    i am waiting for the answer.....plz give me....

  • #6
    Regular Coder
    Join Date
    Mar 2006
    Posts
    238
    Thanks
    3
    Thanked 37 Times in 37 Posts
    I hope your login and password are not sensitive information. You have published them at a public forum. If it is sensitive information, please change these login and password anywhere you ever used them.

    Could you comment out ob_start(); and see which the error would be produced in this case ? Could you try the following:
    PHP Code:
    <?php
    session_start
    ();

    $_SESSION['susername']=$_POST["username"];
    if(
    $_SESSION['susername']=="")
    $ssusername$_SESSION['profileusername'];
    else
    $ssusername$_SESSION['susername'];

    session_write_close();
    header("Location: ./profile.php");
    exit;

    //if($ssusername=="")
    //require "serverbusy.html";

    //session_register("ssusername");
    ?>
    I commented 2 lines below because they are after the redirect. the line
    header("Location: ./profile.php");
    never was in the else-block (you do not have curly brackets so only the 1st statement after else belongs to the else-block). So no matter what you include after redirect, normally the user would not see that anyway ... Please uncomment the lines and remove exit; if you think you could need them.

  • Users who have thanked SKDevelopment for this post:

    srihari3d (09-15-2009)

  • #7
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    i got this error....Cannot send session cookie - headers already sent by ......
    same problem.........the code all are correct.....plz give me the answer...

  • #8
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,306
    Thanks
    4
    Thanked 205 Times in 202 Posts
    Are you showing us index1.php or login.php? The message clearly states that login.php has already sent headers of some sort so, if you're showing us index1.php, the session_start will result in the error.
    Dave .... HostMonster for all of your hosting needs


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •