login script warning... need help

Discussion in 'PHP' started by cgo85, Oct 9, 2008.

  1. #1
    I put together a login script however I'm getting this warning message once i'm redirected to 'logged in' area of website.


    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/..../axiom/myaccount.php:7) in /home/..../axiom/myaccount.php on line 8


    What is causing this? I'm sure it's just something simple that I'm missing.

    This is the code that contains line 8
    <?php
    session_start();
    if (!isset($_SESSION['user']))
    {
     die ("Access Denied");
    }
    ?> 
    PHP:

     
    cgo85, Oct 9, 2008 IP
  2. Sillysoft

    Sillysoft Active Member

    Messages:
    177
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #2
    There is data being sent to the browser before you do the session_start. The session_start has to be set before you send anything to the browser. Its the same for using the header() function.
     
    Sillysoft, Oct 9, 2008 IP
  3. joxtechnology

    joxtechnology Peon

    Messages:
    146
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    make sure theres no content or even space before this code
    <?php
    session_start();
    if (!isset($_SESSION['user']))
    {
    die ("Access Denied");
    }
    ?>
     
    joxtechnology, Oct 9, 2008 IP