Question: This is my index file:

```
session_start();
include_once 'conn.php';
if(isset($_SESSION['hell'])!="")
{
    header("Location: home.php");
}

if(isset($_POST['Login']))
{
    $email = $_POST['email'];
    $pass = $_POST['pass'];
    $res=mysql_query("SELECT * FROM studentreg WHERE email='$email'");
    $row=mysql_fetch_array($res);

    if($row['password']==$pass)
    {
        $_SESSION['hell']=$row['stu_id'];
        header("Location: home.php");
    }
    else
    {
        echo "hello"."<br/>";
        echo $row['password']."<br/>";
        echo $row['qualification'];
    }
}

```

This is my home file:

```
session_start();
include_once 'conn.php';

if(!isset($_SESSION['hell']))
{
    header("Location: index.php");
}

$res=mysql_query("SELECT * FROM studentreg WHERE stu_id = ".$_SESSION['hell']);
$sturow=mysql_fetch_array($res);
echo "welcome";

```

It will not work rather my query is working …why?

Answer: 
What is the error message? Add `ini_set('display_errors', 1);` at top of page to check. 

Maybe there was text printed before the header not letting it redirect? 

Are there spaces before the php opening tag?

Is session variable hell exist from another page?
Try this code:

```
echo "<script>window.location='home.php'</script>";

```