Results 1 to 5 of 5

Thread: Sessions Problem

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2004
    Posts
    1,202

    Sessions Problem

    Hello,

    I keep geting this error can you help me please.

    Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/markhost/public_html/index.php:3) in /home/markhost/public_html/styles/top.php on line 2

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/markhost/public_html/index.php:3) in /home/markhost/public_html/styles/top.php on line 2


    This is top.php code below.

    Code:
    <?php
    session_start();
    $username = $_SESSION['username'];
    $userid = $_SESSION['userid'];
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title><?php echo $title; ?></title>
    <link href="styles/main.css" rel="stylesheet" type="text/css"></link>
    <script language="javascript" src="scripts/javascript.js"></script>
    </head>
    <body>
    
    <div id='wrapper'>
    
    <div id='header'>
    	<div id='status'><?php require('scripts/status.php'); ?></div>
    	<a href='http://www.markhost.biz/'><img src='images/banner.png'></img></a>
    </div>
    
    <div id='nav'>
    <ul>
    <li>
    <a href="http://www.markhost.biz/">Home</a>
    </li>
    <li>
    <a href="#">Free Download</a>
    </li>
    <li>
    <a href="#">Buy Full Version</a>
    </li>
    <li>
    <a href="#">F.A.Q</a>
    </li>
    <li>
    <a href="#">Forums</a>
    </li>
    <li>
    <a href="#">Support</a>
    </li>
    </ul>	
    </div>
    
    <div id='content'>
    come back and mark your original post as resoved if your problem is fixed

    Jamie Garland

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Sessions Problem

    The error message tells you the problem. You can't send headers (start a session) after you've output something. You output something here:
    headers already sent by (output started at /home/markhost/public_html/index.php:3)
    The problem lies on line 3 of index.php.

    Also, extra spaces at the top of your scripts do count as output.
    Like Archer? Check out some Sterling Archer quotes.

  3. #3
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: Sessions Problem

    BOM characters can also cause this problem.
    If you can't find an obvious cause, try saving the file with ANSI encoding.
    Delete it. They just clutter threads anyway.

  4. #4
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Sessions Problem

    You can get around this by turning ON output_buffering in php.ini.

    So ,

    vb Code:
    1. output_buffering = On

  5. #5
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Sessions Problem

    Quote Originally Posted by Jmacp View Post
    You can get around this by turning ON output_buffering in php.ini.

    So ,

    vb Code:
    1. output_buffering = On
    there is absolutely no reason to do this. if you program something correctly, you'll never need to use output buffering to do anything run-of-the-mill.
    Like Archer? Check out some Sterling Archer quotes.

Posting Permissions

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



Click Here to Expand Forum to Full Width