Improve login and logout

This commit is contained in:
Jay Trees 2022-01-18 12:03:04 +01:00
parent 4e7148b8cd
commit 1f68d75b88
2 changed files with 11 additions and 2 deletions

View file

@ -17,8 +17,12 @@ if (isset($_POST['email'], $_POST['password'])) {
AND `password` = "' . sha1($_POST['password']) . '";' AND `password` = "' . sha1($_POST['password']) . '";'
)->fetch(); )->fetch();
if (false === $user) {
# code...
} else {
$_SESSION['user'] = $user; $_SESSION['user'] = $user;
} }
}
if (isset($_SESSION['user'])) { if (isset($_SESSION['user'])) {
header('Location: /?page=home'); header('Location: /?page=home');

View file

@ -10,8 +10,13 @@ use wishthis\Page;
$page = new page(__FILE__, 'Logout'); $page = new page(__FILE__, 'Logout');
if (PHP_SESSION_ACTIVE === session_status()) {
session_destroy(); session_destroy();
header('Location: /?page=logout');
die();
}
$page->header(); $page->header();
$page->navigation(); $page->navigation();
?> ?>