Jump to content

Warning: session_start().. problem


~n[EO]n~

Recommended Posts

Here is my problem :  :( Just need solution...

 

In my menu page, i need to fetch one image from database and that file is included in the homepage.

 

menu.php is the included  file, here i have to fetch the image .

 

index.php is the file where menu.php is included, and header file is also included 

 

<tr>

        <td><?php include("includes/menu.php"); ?></td>

      </tr>

 

And when i open it it gives error

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at

 

session is automatically started from config.php file and it is inclued in contact.php page

require_once("config.php");
require_once("user_info.class.php");

 

and when i keep include("config.php"); in menu.php file it gives error.

 

Is there some way where i can keep the config.php file so that it works for all pages... any help

Link to comment
https://forums.phpfreaks.com/topic/71923-warning-session_start-problem/
Share on other sites

Not quite sure I understand what you mean but it sounds similar to a post I answered just recently.  Don't forget that when you put session_start() in an included or required file it will effectively appear in the middle of the original php file and so will break the rule that it must appear before any output.

 

If the first thing in your php file was require_once("config.php") and then session_start() was the first thing in your config.php file then you should be ok.

please read the Header Pinned Post

 

basically you have sent data to the screen before using session_start()

in fact it tells you that the data was sent from in the message "headers already sent (output started at ######"

 

working example

<?php
session_start();
echo "Hi Mom!";
?>

 

Failed example

<?php
echo "Hi Mom!";
session_start();
?>

 

thats that echo could be in an include used before the session_start();

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.