Improve login and logout
This commit is contained in:
parent
4e7148b8cd
commit
1f68d75b88
2 changed files with 11 additions and 2 deletions
|
@ -17,7 +17,11 @@ if (isset($_POST['email'], $_POST['password'])) {
|
||||||
AND `password` = "' . sha1($_POST['password']) . '";'
|
AND `password` = "' . sha1($_POST['password']) . '";'
|
||||||
)->fetch();
|
)->fetch();
|
||||||
|
|
||||||
$_SESSION['user'] = $user;
|
if (false === $user) {
|
||||||
|
# code...
|
||||||
|
} else {
|
||||||
|
$_SESSION['user'] = $user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_SESSION['user'])) {
|
if (isset($_SESSION['user'])) {
|
||||||
|
|
|
@ -10,7 +10,12 @@ use wishthis\Page;
|
||||||
|
|
||||||
$page = new page(__FILE__, 'Logout');
|
$page = new page(__FILE__, 'Logout');
|
||||||
|
|
||||||
session_destroy();
|
if (PHP_SESSION_ACTIVE === session_status()) {
|
||||||
|
session_destroy();
|
||||||
|
|
||||||
|
header('Location: /?page=logout');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
$page->header();
|
$page->header();
|
||||||
$page->navigation();
|
$page->navigation();
|
||||||
|
|
Loading…
Reference in a new issue