How to secure my PHP webpage from unauthorized Users
<p>I am new in PHP and facing a problem with security.
I use this to redirect unauthorized users if they not logged in.</p>

<pre><code>&lt;?php
session_start();

if(!isset($_SESSION['user_id'])) {
    header('Location: login.php');
}
?&gt;
</code></pre>

<p>It is on every top of my page but when I log in and click my protected page it will redirect to login page instead of original/protected page open and my session variable is set on my login page how to include this session variable in my protected page from login page.</p>
