繁体   English   中英

当使用PHP的Cookie名称登录时,如何限制特定用户的视图

[英]How to restrict the view for particular user when they are login in using cookie name using php

这是我的PHP代码

<?php
require_once('../includes/config.php');
// include file to check, If current user loggedin or not
include('log-security.php');
require_once('../cs/includes/header.php');
if(in_array(cms_username, $allowedUsers))
{
    $allowedUsers=['john', 'akhil'];
    <div id="view8"></div>
}


?>
This is my div id code
<div id="view8" class="tabcontents">
<h3>Creation of  files</h3>
</div>

我是PHP新手,如果错误,请帮助我纠正代码。 当仅登录时,它将限制用户。当输入允许的用户时,应为其他用户显示viewid,但不显示其他用户。

试试这样的事情:

<?php

require_once('../includes/config.php');
require_once('../cs/includes/header.php');

include('log-security.php');
$allowedUsers = array('john', 'akhil');

?>


<?php if (in_array('cms_username', $allowedUsers)): ?>
  <div id="view8" class="tabcontents">
    <h3>Creation of  files</h3>
  </div>
<?php endif; ?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM