I\'ve read several topics like:
Error — session_destroy() — Trying to destroy uninitialized session, Warning: session_destroy(): Trying to destroy uninitialized session
You're calling session_destroy()
twice.
If your cookie isn't set, then it won't equal $_SESSION['email']
will it?
Change your code to:
public function forbidden(){
if(!isset($_SESSION)){ session_start(); }
if(!isset($_SESSION['email']) || !isset($_SESSION['id'])){
$this->error_404();
}else{
if(!isset($_COOKIE['data'])){
session_destroy();
$this->error_404();
} elseif($_COOKIE['data'] != sha1($_SESSION['email'])){
session_destroy();
unset($_COOKIE["data"]);
setcookie("data", false, time() - 3600, '/');
$this->error_404();
}
}
}