经过大量搜索并在会议上工作后,我找到了自己的方式。我希望它对这里的每个人都有效
这是我的用户的登录页面查询:在匹配来自 mysql 的数据后,我将电子邮件存储为来自输入字段的会话
<?php
include_once("dbcon.php");
$que=mysqli_query($con,"select * from agents where companyemail='$email' AND
pass='$password' AND post != 'Owner'");
$record = mysqli_fetch_assoc($que);
$_SESSION[$email]=$email;
header("Location:/dashboard/woresk/Dashboard_For_Agents/light/index.php?
&loginid=$agentid");
?>
然后在用户的仪表板中有一个注销选项,我使用了这种方法
<?php
session_start();
include_once("dbcon.php");
$sid=$_GET['loginid'];
$que=mysqli_query($con,"select * from agents where id='$sid'");
$recorde = mysqli_fetch_assoc($que);
$email=$recorde['companyemail'];
unset($_SESSION[$email]);
header('location:/dashboard/woresk/index.php');
?>
并避免用户在未登录或未设置会话时进入仪表板,以下代码对我很有用
<?php
session_start();
include_once("dbcon.php");
$sid=$_GET['loginid'];
$que=mysqli_query($con,"select * from agents where id='$sid'");
$recorde = mysqli_fetch_assoc($que);
$email=$recorde['companyemail'];
if(isset($_SESSION[$email]) && isset($_SESSION['alllogout'])){
}
else if(!isset($_SESSION[$email])){
echo
"<script>
window.location.href='/dashboard/woresk/index.php'
</script>";
}
else if (!isset($_SESSION['alllogout'])){
echo
"<script>
window.location.href='/dashboard/woresk/index.php'
</script>";
}
?>
我希望这也适用于其他人。如果有任何问题请告诉我