Jump to content

Help me with this wwarning "Warning:session_start()"


Recommended Posts

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home3/nyhungry/public_html/includes/header.php:7) in /home3/nyhungry/public_html/includes/header.php on line 57

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home3/nyhungry/public_html/includes/header.php:7) in /home3/nyhungry/public_html/includes/header.php on line 57

( Hungers)

 

<!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" />
<link type="text/css" href="stylesheets/webpageprueba.css" rel="stylesheet" media="all" />
<title>www.Nyhungry.com</title>
<script type="text/javascript" src="scripts/prototype.js"></script>
<script type="text/javascript" src="scripts/rating.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript">
(
function()
{
  var default_image = $('td.largethumb img').attr('src');
  $('table.smallthumbs a').mouseover(function() { $('td.largethumb img').attr('src', $('img', this).attr('src')); });
});
</script>
</head>


<body>



<div id="sidebar1">
<ul id="mainNav">
      <li id="home"><a href="restaurants/index.php" title="All restaurants inside nyhungry" class="first">Home</a></li>
                <li id="music"><a href="../../Take Outs/Take Outs frontpage.html" title="Information about all take Outs">Hungry for Music!</a></li>
              <li id="pizzerias"><a href="../../Pizzeria/Pizzeria frontpage.html" title="All the pizzerias inside nyhungry">Contact us</a></li>
                   </ul>
<!-- end #sidebar1 --></div>
<!--<table id="restaurantview">

<a href=""><td width="40" id="contenido1">tropiezo></td></a>
<a href=""><td width="40" id="contenido2">colozar1></td></a>
<a href=""><td width="40" id="contenido3">colozar2></td></a>
<a href=""><td width="40" id="contenido4">colozar3></td></a> 
<a href=""><td width="40" id="contenido4">colozar4></td></a>
<a href=""><td width="40" id="contenido4">colozar3</td></a>
</table>-->

<div id="right">

<?php /*?><?php
$data=file_get_contents('counter.dat');
$counter=unserialize($data);
$counter[$_SERVER["REMOTE_ADDR"]]=time();
foreach ($counter as $key => $value) if ($value < (time()-180)) unset $counter($k);
$data=serialize($counter);
file_put_contents('counter.dat', $data);
echo'<p>count($counter)." viewing"</p>';
?> </div><?php */?>

<?php  
session_start(); // this is Line 57 where the warning is coming from... 

/* Define how long the maximum amount of time the session can be inactive. */ 
define("MAX_IDLE_TIME", 3); 

function getOnlineUsers(){ 

if ( $directory_handle = opendir( session_save_path() ) ) { 
$count = 0; 
while ( false !== ( $file = readdir( $directory_handle ) ) ) { 
if($file != '.' && $file != '..'){ 
// Comment the 'if(...){' and '}' lines if you get a significant amount of traffic 
if(time()- fileatime(session_save_path() . '\\' . $file) < MAX_IDLE_TIME * 60) { 
$count++; 
} 
} 
closedir($directory_handle); 

return $count; 

} 
}
else { 
return false; 
} 

} 

echo '(' . getOnlineUsers() . ' viewer)<br />'; ?>

</div>

you can't send headers before any output. the error shows where the output starts (in your case line 7)

Cannot send session cookie - headers already sent by (output started at /home3/nyhungry/public_html/includes/header.php:7)

 

put your php code that sends the header at the top of the page

 

Which one of the three lines below would be the heard to put at the top of the page?

1

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 

2

<link type="text/css" href="stylesheets/webpageprueba.css" rel="stylesheet" media="all" />

 

3

<title>www.Nyhungry.com</title>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.