www.webdeveloper.com
Results 1 to 5 of 5

Thread: Start Session Error..Please help.

  1. #1
    Join Date
    Jun 2011
    Posts
    5

    Start Session Error..Please help.

    Hi,

    I've poked around on the internet for a solution the error message I'm getting, and I have not been successful in resolving the issue. I'm wondering if someone here can help.

    The error message I get is as follows:

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/nellno1/public_html/1999implant.com/zipcodetest/thank-you.php:1) in /home/nellno1/public_html/1999implant.com/zipcodetest/config.php on line 1

    Here is the PHP code on the site.

    From the thank-you.php (this is placed ABOVE the !DOCTYPE ... :
    PHP Code:
    <?php
    require_once('config.php');
    if(isset(
    $_SESSION['user']))
    {
        
    $first_name    $_SESSION['user']['first_name'];
        
    $last_name    $_SESSION['user']['last_name'];
        
    $email        $_SESSION['user']['email'];
        
    $phone_no    $_SESSION['user']['phone_no'];
        
    $pin_code    $_SESSION['user']['pin_code'];
        
    $list_name    $_SESSION['user']['list_name'];
        unset(
    $_SESSION['user']);
    }
    else
    {
        
    header("Location:index.php");
        exit();
    }    
        
    ?>
    On the config.php file:
    PHP Code:
    <?php
    ob_start
    ();
    session_start();
    $local_setting    '';
    $hostName $_SERVER['HTTP_HOST'].$local_setting;
    $docRoot $_SERVER['DOCUMENT_ROOT'].$local_setting;
    I would be very grateful for any help with this.

    Thanks,

  2. #2
    Join Date
    Mar 2011
    Posts
    1,133
    The "headers already sent" error message means that some output has already been generated by your script. At a glance, I'd suspect the 'config.php' file - make sure that it ends with the closing "?>" with no \n after it.
    Rick Trethewey
    Rainbo Design

  3. #3
    Join Date
    Jan 2006
    Location
    MN
    Posts
    440
    The code must also be the first thing on the page, above <html><header>... etc.

    I agree with rtrethewey that config.php needs ending ?>

    You might try it with the config.php merged into the main file too.
    Last edited by Dasher; 08-06-2012 at 07:46 AM.

  4. #4
    Join Date
    Jun 2011
    Posts
    5
    Thanks, that solved it.

  5. #5
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,154
    Actually, it's useful to leave the closing ?> out of included files so that you do not accidentally end up outputting anything after the closing tag. I therefore intentionally leave it out. (The parser assumes it's there when it gets to the end-of-file while in PHP mode.)
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles