PHP中如何实现不同权限进入不同页面
首先在用户登录成功的时候,将用户的权限等级加入Session会话中;
<?php $user_perm_level = 1; session_start(); $_SESSION['user_perm_level'] = $user_perm_level; ?>
然后在访问页面时再将Session中存的权限等级取出来;
<?php session_start(); $user_perm_level = $_SESSION['user_perm_level']; ?>
最后在根据权限等级进行相应的页面跳转即可。
<?php session_start(); $user_perm_level = $_SESSION['user_perm_level']; Switch($user_perm_level){ case 1: header("location: topage1.php"); break; case 2: header("location: topage2.php"); break; case 3: header("location: topage3.php"); break; default: header("location: topage.php"); break; } ?>