I made a site with PHP that the user enters I wanted to do something with cookies in PHP so that when the user enters another header is displayed
<?php
include "database/pdo_connection.php";
$error="";
$errorFild="";
if(
isset($_POST['phone']) && $_POST['phone'] !== ''
&& isset($_POST['password']) && $_POST['password'] !== ''
)
{
if(isset($_POST['sub'])){
$phone=$_POST['phone'];
$password=$_POST['password'];
$smt=$conn->prepare("SELECT `password` FROM users WHERE `phone`='$phone' ");
$smt->execute();
$result=$smt->fetchAll();
if(password_verify($password,$result[0]['password'])){
$result=$conn->prepare("SELECT * FROM users WHERE phone=? ");
$result->bindValue(1,$phone);
$result->execute();
$users=$result->Fetch(PDO::FETCH_ASSOC);
$_SESSION['id']=$users['id'];
$_SESSION['role']=$users['role'];
$_SESSION['phone']=$users['phone'];
**setcookie("phone", $users['phone'], time()+89000);**
header('location:index.php');
}
else{
$error=true;
}
}
}
else{
if( !empty($_POST)){
$errorFild =true;}
}
?>
This is the login page code
<li class="nav-item me-0">
<a class="nav-link mt-3 mt-lg-0" href="/login.php">
<i class="fa fa-sign-in ms-1"></i>
<span>login</span>
</a>
</li>
<li class="nav-item me-0">
<a class="nav-link mt-3 mt-lg-0" href="/register.php">
<i class="fa fa-user-plus ms-1"></i>
<span>register</span>
</a>
</li>
</li>
<li class="nav-item me-0">
<a class="nav-link mt-3 mt-lg-0" href="/codeyadproject2/logout.php">
<i class="fa fa-sign-in ms-1"></i>
<span>logout</span>
</a>
</li>
<li class="nav-item me-0">
<a class="nav-link mt-3 mt-lg-0" href="/codeyadproject2/PANEL/index.php">
<i class="fa fa-sign-in ms-1"></i>
<span>login to panel</span>
</a>
</li>
and index header
my Question:
I want him not to bring me another header when he comes in
For example, instead of logging in and registering, it should log in to the panel, or if it doesn't log in, it won't log in to the panel anymore
What code should I put? (with cookies)