require() results in session and header-sent errors
| From: | Jempty, George | Date: | Mon, 30 Jul 2001 18:38:36 +0000 |
| Subject: | require() results in session and header-sent errors | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-60253@lists.php.net to get a copy of this message | ||
I'm trying to prototype the framework for some intranet
applications. I begin with a login.php script. At the VERY top, of this
script, I require a file as follows:
require("intranet_ini.php");
This contains some constant definitions, and one function; here is
the code:
<?
define("INTRANET_DB","intranet");
define("INTRANET_APPS_TABLE","apps");
define("INTRANET_APPS_FOLDER","apps");
define("INTRANET_FOLDER","/"); //Server Root
define("INTRANET_TEST_PASSWORD","test");
function Login_Success($thisAppFolder, $thisPassword)
{
session_start();
global $sess_TestMode;
session_register("sess_TestMode");
$sess_TestMode = ($thisPassword == INTRANET_TEST_PASSWORD);
global $sess_AppDB;
session_register("sess_AppDB");
$sess_AppDB = $thisAppFolder;
$appBaseUrl = INTRANET_FOLDER . INTRANET_APPS_FOLDER;
header("Location: $appBaseUrl/$thisAppFolder/");
}
?>
The script works fine like this: it redirects the page. HOWEVER....
I've decided I want to remove the function above into it's own file,
"login_funcs.php". For the time being it will be the only function in said
file. I cut and pasted the function, and added:
require("login_funcs.php");
directly underneath the line requiring intranet_ini.php, so in
essence I am still including the very same lines of code, in the very same
order. However, when the Login_Success function is called, the following
errors stump me:
Warning: Cannot send session cookie - headers already sent by
(output started at c:\intranet\login_funcs.php:1) in
c:\intranet\login_funcs.php on line 4
Warning: Cannot send session cache limiter - headers already sent
(output started at c:\intranet\login_funcs.php:1) in
c:\intranet\login_funcs.php on line 4
Warning: Cannot add header information - headers already sent by
(output started at c:\intranet\login_funcs.php:1) in
c:\intranet\login_funcs.php on line 15
PS....using include() does not solve this problem. Thanks in
advance for any ideas.
George M Jempty
Database Administrator
Regional West Medical Center
Scottsbluff, Nebraska
308.630.2408