当我登录时,会进入主页面的副本,并修改了一些元素,有没有办法做到这一点,否则将要创建每页2份?
发布于 2018-07-27 09:15:29
可以使用类似的方法
... existing page content ...
if($_SESSION['LoggedIn']){
... add content for logged in users
}
... existing page content ...
当用户登录时,只需设置:
$_SESSION['LoggedIn'] = true;
然后你可以在任何地方添加内容
在成功登录时:
$_SESSION['UserToken'] = 'aabbcc'; //Use a valid identifier to find the user in your database
检查用户是否对页面上的项具有访问权限时:
$SecurityLevel = 5;
if(userHasAccess($_SESSION['UserToken'], $SecurityLevel)){
... add content for logged in user ...
}
需要实现userHasAccess函数
function userHasAccess($UserToken, $SecurityLevel){
//Look up user token in DB to get user details
//Perform some logic to determine if the user should have access to this resource, based on the security level
//Return true if they are allowed
//Return false if they are not allowed
}
https://stackoverflow.com/questions/-100001693
复制相似问题