I have two inc files I call from all my pages to keep track of sessions. But on all the pages where I include the files these errors come up. I am a newbee and don't understand these errors.
Warning: Cannot send session cookie - headers already sent by (output started at funccontdb.inc:28) in funcsession.inc on line 2
Warning: Cannot send session cache limiter - headers already sent by (output started at funccontdb.inc:28) in funcsession.inc on line 2
I can't figure out why these errors are coming up or what they even mean. Here is a copy of the code in the .inc files.
funccontdb.inc
<?php
$link;
connectToDB();
function connectToDB()
{
global $link;
$link = mysql_connect( "localhost", "jhyers", "careinx" );
if ( ! $link )
die ("Couldn't connect to MySQL" );
mysql_select_db ( "careinternet", $link )
or die ( "Couldn't open $db: ".mysql_error() );
}
function getRow( $table, $fnm, $fval )
{
global $link;
$result = mysql_query( "SELECT * FROM $table WHERE $fnm='$fval'", $link );
if ( ! $result)
die ( "getRow fatal error: ".mysql_error() );
return mysql_fetch_array( $result );
}
function newUser ( $username, $pass )
{
global $link;
$result = mysql_query( "INSERT INTO login (username, password)
VALUES('$username', '$pass')", $link);
return mysql_insert_id( $link );
}
?>
funcsession.inc
<?php
session_start();
session_register( "session" );
function cleanMemberSession ( $id, $username, $pass )
{
global $session;
$session[id] = $id;
$session[username] = $username;
$session[password] = $pass;
$session[logged_in] = true;
}
function checkUser( )
{
global $session, $logged_in;
$session[logged_in] = false;
$club_row = getRow ( "login", "id", $session[id] );
if ( ! $club_row ||
$club_row[username] != $session[username] ||
$club_row[password] != $session[password] )
{
header( "location: login.php" );
exit;
}
$session[logged_in] = true;
return $club_row;
}
?>