PHP包含页面内容不刷新

i have a serious problem over here. I created a user system with sessions. The problem is that there is content you only see when you are logged in. For example in the navigation bar the sign in button is replaced with a account button.

Now to my problem: Every page php-includes the navbar.php. For example in the index.php is written:

<body>
<?php include("navbar.php")?>
</body>

The login.php redirects to the index.php:

header("Location: index.php");

But the index.php does not refresh. After a hard refresh with "F5" every thing is fine.

I also tried meta tags to prevent loading the page in the cache.

Any Ideas?

index.php:

<html lang="en">
<head>
    ...
</head>
<body >
<?php include("navbar.php")?>
    <div id="wrap">
    ...
    </div>
</body> 
</html>

navbar.php

<div class="navbar">
    <?php
    session_start();
    if (!isset($_SESSION['logged']) || !$_SESSION['logged']) 
    {?>
      ...Sign in etc...
    <?php
    }
    else
    {?>
        ...Accounting...
    <?php
    }?>
</div>

login.php:

<html>
<head>
</head>
<body>
<?php include("navbar.php"); ?>
<div class="container">
  <form class="form-signin" action="logon.php" method="post" >
        ...
    <button type="submit">Login</button>
  </form>
</div>
</body>
</html>

logon.php:

<?php
if login successfull //pseudo code
    header("Location: http://www.***.com/index.php");
}
else 
{
    header("Location: http://www.google.de");
}
exit;
?>

According to the specs, you have to pass an absolute uri.
It's also best to add this, when redirecting:

header('HTTP/1.1 301 Moved Permanently');
header('Location: https://www.google.com');

For SEO purpouses, and browser cache (google this to find out more).
I hope you know this already, but you'll also have to make sure no output has been sent to the client, because in that case, the headers have already been sent, and logic dictates that it's too late to change them, then.

Check this question for more details on how to deal with headers and output buffering.

add this to your .htaccess file. this will disable browser caching on these file extensions

 <FilesMatch ".(pl|php|cgi|spl|scgi|fcgi)$">
 Header unset Cache-Control
 </FilesMatch>