redirect to login as part of session check : <p>for the life of me can't get the header redirect or the java redirect to work in this lock.php </p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
include 'config.php' ;
session_start();
$user_check=$_SESSION['login_user'];

$ses_sql=mysqli_query($db,"select username from users where username='$user_check' ");

$row=mysqli_fetch_array($ses_sql,MYSQLI_ASSOC); //confirm username from users table

$login_session=$row['username'];

if ($login_session ==""){
    // echo "the variable is empty"; //when i check this works here.
    //header ("Location: login.php"); //redirect to login -tried this, fail
    echo "&lt;script&gt; location.href='login.php'; &lt;/script&gt;"; // tried this, fail
    exit(); //stop execution of any further script
}

?&gt;</code></pre>
</div>
</div>
</p>
