How to set session for login and logout in php?
<p>I have created session and destroying session in logout.php but if i entered in url(<a href="http://localhost/demo/home.php)it" rel="nofollow">http://localhost/demo/home.php)it</a> showing loggedin.It should be redirect on index.php or display page not found.</p>

<p>What i am achieving- I have login section and there is no issue in that.I am able to login with my credentials and page is redirecting on home.php successfully.From home.php i have logout link and i clicked on that page is redirecting on index.php but if i entered  home.php showing loggedin..
Please help me in this.</p>

<p><strong>index.php</strong></p>

<pre><code>session_start();

$username = $_POST['username'];
 $password = $_POST['password'];

$sel_user = "SELECT * FROM admin WHERE Username='$username' and Password='$password'";
$run_user = mysqli_query($conn, $sel_user);

$check_user = mysqli_num_rows($run_user);

if($check_user&gt;0){

echo "&lt;script&gt;window.open('home.php','_self')&lt;/script&gt;";
$_SESSION['user_email']=$username;

}

else {

$msg="Username and Password is incorrect.";


}
</code></pre>

<p><strong>Home.php</strong></p>

<pre><code>&lt;h2&gt;Home page&lt;/h2&gt;
&lt;a href="logout.php"&gt;logout&lt;/a&gt;
</code></pre>

<p><strong>logout.php</strong></p>

<pre><code>       &lt;?php
         session_start();
        if(session_destroy())
                {
                header("Location: index.php");
                }
                ?&gt;
</code></pre>