I would like to separate my source folders into two: The folders that contain the code that you type into the address bar and those that make up parts of the page (tiles) and other code (classes, etc). So at the start of every php file I added:
<?php
// index.php
include("config.php");
include("session.php");
?>
Config contains just this so far, but allows me to expand if I need other directories (logs, etc.)
<?php
// config.php
$_PATHS["base"] = dirname(dirname(__FILE__)) . "\\";
$_PATHS["includes"] = $_PATHS["base"] . "includes\\";
ini_set("include_path", "$_PATHS[includes]");
?>
And session has amongst other things, in the constructor, a call to session_start
. It also requires other classes which are included elsewhere - which necessitates the config being listed before the session inclusion. However I get the error
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started ...
If I switch the includes around that particular error goes away but I need to start manually munging the links to the header files. Is there anyway of setting the directories first and still being able to use sessions or must session_start
be the very first thing the a file includes?