代码安全隐患(散分)
刚发现自己写的一段验证代码有严重的安全隐患,请大家指教。代码的目的是先通过判断SESSION变量是否注册及其值是否合法,如果验证失败就跳转到登录页面,如果成功才继续往下执行:
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><?php session_start(); //$_SESSION['gid'] 是用户登录成功时注册的变量,值1代表管理员组 if (!isset($_SESSION['gid']) || ($_SESSION['gid'] != 1)) { header("location:login.php?".SID); } //do some thing here ?>
<?php header("Location: http://www.example.com/"); /* Redirect browser */ /* Make sure that code below does not get executed when we redirect. */ exit; ?> <div class="clear"> </div>