Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2006
    Posts
    41

    Unanswered: Warning: session_start(): Cannot send session cookie - headers already sent

    Hi,

    I have uploaded a webpage I created and get the following messages at the top of the page:

    Code:
    Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/gamerfo/public_html/index.php:2) in /home/gamerfo/public_html/index.php on line 3
    
    Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/gamerfo/public_html/index.php:2) in /home/gamerfo/public_html/index.php on line 3
    The part of my code that's causing the problem is :

    Code:
    <html>
    <?php 
    session_start();
    $loggedin = $_SESSION['loggedin'];
    ?>
    <head>
    
    <style type="text/css">
    
    a1:link { 
    	color: #CCCCCC;
    	}
    a1:visited { 
    	color: #FFFFFF;
    	}
    a1:hover { 
    	color: #CCCCCC;
    	background-color: #333333;
    	text-decoration: none;
    	}
    a1:active { 
    	color: #333333;
    	}
    
    
    .menu1{
    background-image:url(images/menudiv1bg.gif);
    padding-top:2px;
    font:Arial, Helvetica, sans-serif;
    color:#CCCCCC;
    padding-bottom: 2px;
    display:block;
    text-decoration: none;
    color: #000000;
    height: 20px;
    }
    
    
     .submenu{
    background-image:url(images/submenu.gif);
    display: block;
    font:Arial, Helvetica, sans-serif;
    height: 20px;
    margin-left: 20px;
    padding-top: 2px;
    padding-left: 7px;
    color: #333333;
    }
    
    .hide{
    display: none;
    }
    
    .show{
    display: block;
    }
    .style5 {
    	font: Arial, Helvetica, sans-serif;
    	padding-bottom: 2px;
    	display: block;
    	text-decoration: none;
    	height: 20px;
    	background-image: url(images/menudiv1bg.gif);
    	padding-top: 2px;
    	color: #CCCCCC;
    }
    .style18 {font: Arial, Helvetica, sans-serif; padding-bottom: 2px; display: block; text-decoration: none; height: 20px; background-image: url(images/menudiv1bg.gif); padding-top: 2px; color: #CCCCCC; font-family: Verdana, Arial, Helvetica, sans-serif; }
    .style19 {font-family: Verdana, Arial, Helvetica, sans-serif}
    
    .style20 {
    	font-family: Arial, Helvetica, sans-serif;
    	font-size: 16px;
    	color: #CCCCCC;
    }
    .style23 {
    	color: #999999;
    	font-family: Arial, Helvetica, sans-serif;
    }
    </style>
    
    
     <script language="JavaScript" type="text/JavaScript">
    <!--
    menu_status = new Array();
    
    function showHide(theid){
        if (document.getElementById) {
        var switch_id = document.getElementById(theid);
    
            if(menu_status[theid] != 'show') {
               switch_id.className = 'show';
               menu_status[theid] = 'show';
            }else{
               switch_id.className = 'hide';
               menu_status[theid] = 'hide';
            }
        }
    }
    
    //-->
    </script>
    
    
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>

    Could someone explain what's going on and how to solve the problem.

    Thanks

  2. #2
    Join Date
    Apr 2006
    Location
    Denver, Co. USA
    Posts
    242
    You cannot send any output to a browser before the session_start() statement. In your file, the <html> tag is sent before the session_start() statement. You must send this tag after the session_start() statement;

  3. #3
    Join Date
    Mar 2006
    Posts
    41
    Thats excellent thanks

    I'll post a link to my website when it's fully operational. I'm sure you'd love to see the fruits of my labour since you helped (not only here but also here and here)

  4. #4
    Join Date
    Mar 2006
    Posts
    41
    You can view my website here. I'd really appreciate your opinions.

    It's a gaming news site where people can easily add news articles and comment on the news articles. It's my first attempt at a dynamic website and would appreciate any advice

Posting Permissions

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