I have a website that contains a login and when the user is logged in I want it to display a message on the main page as well as carry the session on through.

I am receiving the error:

```
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by..

```

and 

```
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent

```

When I am not logged in it displays the error, but as soon as I log in and return to the page it disappears, but doesn't display the "You are logged in!" like it should...

Here is my authentication code after it checks the database for a match:

```
if ($result["userName"] == $_POST[txtUsername] && $result["password"] ==$_POST[txtPassword])
    {
        ?>
        <script type="text/javascript">;
        alert("successfully logged in, <?php echo $result['userName'];?>!");
        window.location.href='http://manning3.jcu.edu.au/~jc192699/index.html';
        </script>
        <?php
        session_start();
        $_SESSION["access"] = 'granted';
    }

```

And my code in my index.php that seems to cause the error:

```
 <?php
    session_start();
    if ($_SESSION["access"] == 'granted'){
        ?>
        <p>You are logged in!</p>
        <?php
    }
    else{
    ?>
    <p>You are not logged in!</p>
    <?php
    }
    ?>

```

Any help would be GREATLY appreciated. Thank you!