First thing I notice is that you set pass as id of 2 to the index.php, don't know if that's intentional.
Secondly there's nothing to do with sessions there
Also you go the long way round - you select all users, then perform a where clause on them in PHP
Here's my php login code, complete with session aswell:
// Connect to DB
include 'ez_sql.php';
session_start();
// See how many users have the same credidentials as us
$username = str_replace("'","",$username);
$hash = crypt($username, $password);
$user = $db->get_row("SELECT * FROM users WHERE username='$username' AND hash='$hash'");
if($user)
{
// Take our name, and give us the permissions
session_register("auth");
$auth = $user->perms;
session_register("uname");
$uname = $user->username;
session_register("uid");
$uid = $user->id;
header("Location: ../index.php?loggedin=y");
} else {
session_destroy();
header("Location: ../index.php?failed=yes");
}