Session not working

OKay. So I am using the same server and coding that I always use to connect to the database and start a session when a user logs into a CMS I have. Now, all I have done is copy all of the files onto another domain like I usually do, but this time it’s not working. I am pretty sure that the session is not holding for some reason because I told it to send me to a certain spot if there is not a session currently started on the index page.

Maybe something is wrong with my code?

This is the submit page from the login that should make the session start and usually holds is across multiple pages:


<?php
$username = "user";
$password = "pass";
$database = "db0";
$hostname = "host"; 

//connection to the database
$handle = mysql_connect($hostname, $username, $password, $database)
 or die("");
echo "";

//select a database to work with
$selected = mysql_select_db("db0",$handle)
  or die("Could not select db0");

session_start();
$usernamelog = $_POST['username'];
$passwordlog = sha1($_POST['password']);
$query="SELECT username,password FROM users WHERE username='".$usernamelog."' and password='".$passwordlog."'";
$result = mysql_query($query) or die(mysql_error() . " ------ " . $query);


if(!$result) {
$err=mysql_error();
print $err;
exit();
}
if(mysql_affected_rows()==0){
header('Location: login2.php');

exit();
}
else{
$_SESSION['username2009'] = $usernamelog;
$variable = $_SESSION['username2009'];
$result = mysql_query("SELECT is_admin FROM users WHERE username = '$variable'")
or die(mysql_error());  
$data = mysql_fetch_array($result, MYSQL_BOTH);

if ( $data['is_admin'] == 0 ) {
header('Location:  URL');
echo $data['is_admin'];
}
else if ( $data['is_admin'] == 1) {
header('Location: URL');
} 
else if ( $data['is_admin'] == 2) {
header('Location: URL');
}
}
?>

And here is the index.php page that sees if there is a session:


if(!$_SESSION['username2009']){
    include ("URL");
    exit();
}

Thanks so much. I am really stressing on this because it always works!