I want to log out

<?php
require_once('database.php');
require_once('upper.php');
$LoginId=$_COOKIE['LoginIdCookie'];
$query="SELECT * FROM registration WHERE LoginId='$LoginId'";
$result=mysqli_query($dbc,$query) or die('Not Connected');
$row=mysqli_fetch_array($result);
if(isset($_COOKIE['LoginIdCookie']))
{
setcookie('LoginIdCookie',$row['LoginId'],time()-3600);
echo 'Log';
}
else
{
setcookie('AdminCookie','A',time()-3600);
}

//$home_url='http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/LoginValidator.php';
//header('Location: LoginValidator.php');
echo "You are logged out successfully.<br><br>";
echo $LoginId;
//echo "<a href='index1.php'>Back to Home</a>";
require_once('lower.php');
?>

HI friends…
By above code I m not logged out even it displays “You are logged out successfully”…
After click on back button I can do everything…
So please tell me where I am wrong???
Anyone plzzzzzzzzzz/////

No need for database connection for this…
Simply do like this…

if(isset($_COOKIE[‘LoginIdCookie’]))
{
setcookie(‘LoginIdCookie’,‘gone’,time()-3600);
echo ‘Log’;
}
else
{
setcookie(‘AdminCookie’,‘gone’,time()-3600);
}
echo “You are logged out successfully.<br><br>”;
echo “<a href=‘index1.php’>Back to Home</a>”;
require_once(‘lower.php’);
?>