co.ador Posted November 8, 2009 Share Posted November 8, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/180780-help-me-with-this-wwarning-warningsession_start/ Share on other sites More sharing options...
mikesta707 Posted November 8, 2009 Share Posted November 8, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/180780-help-me-with-this-wwarning-warningsession_start/#findComment-953743 Share on other sites More sharing options...
co.ador Posted November 8, 2009 Author Share Posted November 8, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/180780-help-me-with-this-wwarning-warningsession_start/#findComment-953747 Share on other sites More sharing options...
mikesta707 Posted November 8, 2009 Share Posted November 8, 2009 Neither of those... put session_start() at the top of your page Quote Link to comment https://forums.phpfreaks.com/topic/180780-help-me-with-this-wwarning-warningsession_start/#findComment-953748 Share on other sites More sharing options...
co.ador Posted November 8, 2009 Author Share Posted November 8, 2009 <?php header('Content-type: text/html; charset=utf-8');?> The code above would be ok to put on top instead of the meta tags currently inserted in the heard.php Right? Quote Link to comment https://forums.phpfreaks.com/topic/180780-help-me-with-this-wwarning-warningsession_start/#findComment-953749 Share on other sites More sharing options...
co.ador Posted November 8, 2009 Author Share Posted November 8, 2009 like this <?php> session_start(); ?> Before the Doctype right? Quote Link to comment https://forums.phpfreaks.com/topic/180780-help-me-with-this-wwarning-warningsession_start/#findComment-953750 Share on other sites More sharing options...
mikesta707 Posted November 8, 2009 Share Posted November 8, 2009 well more like <?php session_start(); ?> but yes Quote Link to comment https://forums.phpfreaks.com/topic/180780-help-me-with-this-wwarning-warningsession_start/#findComment-953752 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.