Ok, I had a similar, if not the same, problem and this is what I had to do to fix it:
<?PHP
session_start();
session_register('user_id');
session_register('security');
session_register('include_dir');
session_register('temp_var1');
session_register('temp_var2');
session_register('temp_var3');
session_register('temp_var4');
This is at the TOP (very first line) of all my pages. I tried to do what you're doing had start the session in the middle of the page and I got tons of erros. Once I moved it to the top...they all dissappeared and now I never seen any session errors.
Try this for you're code and see if it solves your problems
<?
session_start();
session_register('first_name');
session_register('user_id');
##### Login Script
///// Include header and set page title
$PAGE_TITLE='Login';
include('inc_header.php');
if (isset($_POST['submit']))
{
$message=NULL; ///// Empty variable
///// Check for Username
if (empty($_POST['username']))
{
$u=FALSE;
$message .='You forgot to enter your username.<br>';
} else {
$u=escape_data($_POST['username']);
}
///// Check for Username
if (empty($_POST['password']))
{
$p=FALSE;
$message .='You forgot to enter your password.<br>';
} else {
$p=escape_data($_POST['password']);
}
if ($u && $p) ///// If everything is okay
{
///// Retrieve the id and fname for that username/password combo
$query="SELECT id, fname FROM $TBL_Mem WHERE alias='$u' AND password=PASSWORD('$p')";
$result=@mysql_query($query); ///// Run the query
$row=mysql_fetch_array($result, MYSQL_NUM); ///// Return a record if exists
if ($row) ///// A record was pulled from the database
{
///// Set cookies and redirect
$first_name=$row[1];
$user_id=$row[0];
header("Location: [url]http://[/url]" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/cpanel.php");
exit(); ///// Quit the script
} else { ///// No record matched the query
$message='The username and password did not match those on file';
}
} else {
$message .='Please try again';
}
} ///// End of the Submit conditional
///// Print message if there is one
if (isset($message))
{
echo '<font color="#CC0000">'.$message.'</font>';
}
?>