将PHP变量传递给div中加载的页面

I am trying to pass PHP variable into a series of pages loading in a div within the admin page . Once I click a link a link the page refreshes and i am directed to login page. I tried to start a session in admin.php and put the variable in $_SESSION, but this didn't make sense.I am still directed to the login.php.

<?php

 $_SESSION['user_id']=$_GET['msg'];

 if(!isset($_SESSION['user_id'])){
    # redirect to the login page
    header('Location: login.php?msg=' . urlencode('Login first.'));
    exit();
}  

?>

<li><a href='admin.php?url=addnews.php'><span> News</span></a></li>
<li><a href='admin.php?url=addarticles.php'><span>Articles</span></a></li>

</div>

You haven't called session_start before setting your session variables, and as a result the session data is not being saved between page refreshes or redirects.

<?php
session_start();
$_SESSION['user_id'] = $_GET['msg'];