Improve login and logout
This commit is contained in:
parent
4e7148b8cd
commit
1f68d75b88
2 changed files with 11 additions and 2 deletions
|
@ -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');
|
||||||
|
|
|
@ -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();
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue