PHP SESSION variable not working at the 1st time
<p>Session variables are not set at the first time. From action.php it goes to employee.php But in employee.php $_SESSION['EmpID'] shows nothing when I log in for the 1st time. If I log out and log in again then works fine.  works fine in localhost.</p>

<pre><code>action.php

&lt;?php
session_start(); 
if(isset($_POST['UserID'])&amp;&amp;isset($_POST['Password']))
{
$id = $_POST['UserID'];
$pass = $_POST['Password'];
$result = mysqli_query($con,"select * from auth_det where     UserName='$id' and Password='$pass'");
if(mysqli_num_rows($result)&gt;0)
{
$row = mysqli_fetch_array($result);
//echo $row['UserID'];
//echo $row['Password'];
                $_SESSION['UserName']=$id;
                $_SESSION['EmpID'] = $row['EmpID'];
        $_SESSION['is_auth'] = true;
            $_SESSION['User'] = "Emp";
               echo "&lt;script type='text/javascript'&gt;window.location.href = 'Employee/employee.php'; &lt;/script&gt;";
                 exit();
</code></pre>

<p>}  </p>

<pre><code>logout.php
&lt;?php
session_start(); 
session_destroy();
echo "&lt;script type='text/javascript'&gt; document.location = '../login.php'; &lt;/script&gt;";
?&gt;


employee.php

session_start(); 
$EmpID=$_SESSION['EmpID'];
echo "EmpID=".$EmpID;
if(!isset($_SESSION['EmpID']))
{
echo "&lt;script type='text/javascript'&gt; window.location.href = 'logout.php'; &lt;/script&gt;";
}
</code></pre>