php 中最简单的办法
<?
 if ($_session["adminname"]=="")
{
     echo "<script>alert('您未登录,请先登录');location.href='login.php';</script>";
     exit;
}
?>